• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JSP/form/servlet - session persistence ?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
URL rewriting.
 
Louis Cypher
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://onjava.com/pub/a/pub/a/onjava/2002/05/08/jstl.html?page=2
 
Louis Cypher
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic