Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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.
 
Something about .... going for a swim. With this tiny ad ...
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic