Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

JSP/form/servlet - session persistence ?  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

a JSP page contains a from that, when submitted calls a servlet (specified in the action attribute) that sets an attribute in the session scope and gets back to the jsp page ( it besides the form contains a few jstl tags that display the data entered in the form.)

Now, when cookies are enabled, everything works fine, but when they are not, I can't figure out how to maintain a single session across jsp -> servlet -> back to jsp

What is the best practice approach in my case ?

Regards!
 
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
URL rewriting.
 
Louis Cypher
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
URL rewriting is what I'm trying to introduce but how do I send a sessionid back to jsp ?

Something like :

String url = response.encodeURL("page.jsp");
RequestDispatcher rd = getServletContext().getRequestDispatcher(url);
rd.forward(request,response);

?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
 
Louis Cypher
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I got it :

<c:url var="url" value="servletURL" />
<form action="${url}" method= ......

in the jsp will do the job.

Please correct me if I'm wrong or suggest a more convenient way ( if any) to achieve the same ...

Regards,
Louis
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope, that's about it. You could use the url tag inside the form tag "action" attribute, but that can look a little messy-matter of preference.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!