Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 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

Problem with JSP app

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a major problem, the JSP app has started behaving differently since SSL was applied.
Before:
A user fills out a form (jsp1), when they click submit they are taken to a JSP controller page (jsp2) that runs checks for errors and business logic. If any errors are found they are forwarded to an error page (jsp3) stating the error message(s), they can click the back button (javascript window.history.back()) which then goes to jsp1, with their fields still containing their details.
But now with SSL when the user clicks back they are taken to a new instance of the form, which is empty. (The users will not like this!)
I know I need to use the session object to acheive getting the users data back into the form, but I'm not quite sure how to do this, I keep getting null pointer exceptions.
Can someone point me to some documentation or explain it to me? This would be most appreciated.
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're familiar with servlets, you can use the HttpSession object to store your session data as attributes. Same thing happens in a JSP, noting that every JSP page has an implicit reference to current session called session.
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sharon,
I would like to recommend that you use Struts, an open source MVC framework from The Jakarta Project. You might be using Model 1 in your JSP app, but believe me it's all worth it if you try out Struts.
Struts has so-called ActionForm objects which are tied to forms (obviously). These are session-based so the form fields' values are retained until the session lasts. What's novel is that, just tell Struts that this form has a corresponding ActionForm object, and Struts will automatically tie that form to the ActionForm object for you. Also, ActionForm objects perform field validation when the form gets POSTed so it is another added convenience.
If you are pressed on time, you can use a session bean to track down values of fields in a form, but basically you're just reinventing the wheel.
GL
Ex Animo Java!
-- Val
[ June 25, 2002: Message edited by: Val Pecaoco ]
 
Sharon Cowling
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your comments. Unfortunately this app has been written in JSP with a few java classes attached...I will definetely look into Struts on a future java project.
 
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
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