• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Space in Session object

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've got a servlet that sets some session data:

private void updateSessionData(HttpServletRequest request, int userLevel){
HttpSession session = request.getSession( true );
session.setAttribute( "userName", userName );
session.setAttribute( "password", password );
session.setAttribute( "groupName", groupName );
session.setAttribute( "userLevel", userLevel );
}

And a .jsp page that displays the userName:

<%
String uName = (String)session.getAttribute( "userName" );
if ( uName == null ){
response.getWriter().println( "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=http://69.250.174.31/nfl/index.html\">");
response.getWriter().close()
; }
%>
...
...
...
Name: <INPUT maxLength=25 size=25 name=name
disabled="disabled" value=
<%=uName" )%>
>
...
...

There seems to be a problem if the userName has a space in it. If the userName is "Ken F.", the page is rendered thusly:

<input maxlength="25" size="25" name="name" disabled="disabled" value="Ken" f="">
.......

What's going on?

k
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sloppy HTML. Be sure to put quotes around each and every attribute in your HTML template text.
 
Ken Clark
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry - actually, it was a bad copy/paste. That line should be:

<%=uName %>
 
Ken Clark
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forgot to mention - adding explicit quotes around the field worked.

thanks, k
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic