• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

session.getAttribute?

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this mite seem very familiar...

i have a jsp page that submits some data

<form method="GET" action="submit.jsp">
<INPUT name="firstname" type="text" id="firstname" size="50" maxlength="60" value="" class="mainbodyfont"><%
String firstname = request.getParameter("firstname"); session.setAttribute("firstname",firstname);
%>


and a jsp page
<%= session.getAttribute("firstname") %>



For some reason the jsp page shows "null" value when I submit the form?
Is there any significance to where the scriplet should be in the jsp page i.e. outside the form tags?

Regards
Ali
[ March 12, 2008: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're dealing with two different requests,
The first draws the page with the form in it.
That request will not have any form parameters so getParameter will return null. Because that returns null it will be adding a null attribute to session.

If you put this:

in 'submit.jsp' then the parameter 'firstname' will be populated.
 
Ashimashi Kabashi
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont think that session has a getParameter function..

I have to use the "session" object.
 
Sheriff
Posts: 67682
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

Originally posted by Ashimashi Kabashi:
I have to use the "session" object.

You cannot use the session to retrieve submission parameters. They are present on the request.
 
Ashimashi Kabashi
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
awesome! Thanks
 
Honk if you love justice! And honk twice for tiny ads!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic