This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

page redirection with out losing values  RSS feed

 
shyamkumar bopannachengalaiah
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i had designed a page called s.jsp where i am entering the values in the text fields and as i enter the submit button the values are validated in check.java servletpage ,if the validation returns false the response has to be redirected to the s.jsp with out losing the values that i had entered first. but my values are lost . How can i retrieve this problem ? i should not lose my values.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Create a bean for input values on s.jsp.
In Servlet code, validate the properties, if they fails to validate , set the baen values to the previous value s coming from form.
Forward to s.jsp pages.

And use the EL for accessing request attribute values in JSP page, like

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should do a forward, not a redirect. A redirect creates a new request, hereby dropping the originating request where the parameters/attributes are in.

You may find this article useful as well, it also handles validation in plain JSP/Servlet: http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jspservlet.html
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:

You may find this article useful as well, it also handles validation in plain JSP/Servlet: http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jspservlet.html


And the above code I pasted is taken from the same article. Good Blog BalusC
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!