Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with JSP app

 
Sharon Cowling
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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.
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • 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.
 
Val Pecaoco
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic