Results 1 to 4 of 4
  1. #1
    Turk80 is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Angry Error: "Invalid character constant"

    I'm getting the following error in NetBeans:

    unclosed character literal

    not a statement

    unclosed character literal
    And this message on Tomcat when trying to compile:

    org.apache.jasper.JasperException: Unable to compile class for JSP:

    An error occurred at line: 26 in the jsp file: /categories.jsp
    Invalid character constant
    23: <body>
    24: <table border='5'>
    25: <jsp:useBean id="StockBean" class="HWpackage.StockBean" scope="request">
    26: <jsp:setProperty name="StockBean" property="totalcost" value="<%=request.getAttribute('StockBean')%>" />
    27: </jsp:useBean>
    28: <tr>
    29: <th>Welcome <%UserBean currentUser = (UserBean) (session.getAttribute("currentSessionUser"));%><%= currentUser.getUsername()%></th>
    I'm officially about to start pulling out my hair.

    I know it has to do with this part on line 26:

    Java Code:
    value="<%=request.getAttribute('StockBean')%>" />
    I did have it like this originally and NetBeans liked it but Apache did not:

    Java Code:
    value="<%=request.getAttribute("StockBean")%>" />
    I figured out it had to do with the double quotes within double quotes which as to do with new vs old way of coding on Apache. But I just can't figure out how to correct it in a way that will allow the code to compile.

    Thanks for the help everyone.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

    Default

    If you have quotes inside a String you need to escape them.

  3. #3
    Turk80 is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by Junky View Post
    If you have quotes inside a String you need to escape them.
    If I do that:

    Java Code:
    <jsp:setProperty name="StockBean" property="totalcost" value="<%=request.getAttribute(\"StockBean\")%>" />
    I get:

    Illegal character: \92

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

Similar Threads

  1. Replies: 3
    Last Post: 01-31-2011, 09:46 AM
  2. Replies: 5
    Last Post: 06-22-2010, 03:51 PM
  3. Replies: 3
    Last Post: 03-03-2010, 12:23 AM
  4. Replies: 1
    Last Post: 11-20-2009, 07:58 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •