Discussions

Web tier: servlets, JSP, Web frameworks: Compiling Error: Attribute username has no value

  1. HI every body,

    Can any one tell me what I am doing wrong? when compiling a jsp an error saying:
      "Attribute username has no value".

    <logic:notPresent
      scope="request"
      parameter="<%=(String)request.getAttribute("username")%>
    <logic:forward name="some global forward">

    Thank you in advance
    A
  2. Check to make sure your attribute name is spelled correctly. This is a commone problem I used to have when I wasn't paying attention.
  3. Not sure what app server you're using, but you may need to escape the quotes within the scriptlet tag:

    <logic:notPresent
      scope="request"
      parameter="<%=(String)request.getAttribute(\"username\")%>" />
    <logic:forward name="some global forward" />

    Looks stupid, I know, but you used to have to do this with Tomcat or WebSphere I think.
  4. Sorry guys, I was not able to reply back to your feedbacks. I was out of my office all this time. your suggestions make sense I will give them a try, thank you again.
    ED
  5. Simon, Thank you !!

    I was pulling my hair out over this and once I would have gone completely bald, I was going to burn my websphere box...

    But your post saved my hair and the box :-)

    Using single quote also worked for me:

    <logic:notPresent
      scope="request"
      parameter='<%=(String)request.getAttribute("username")%>' />
    <logic:forward name="some global forward" />

    Thanks