File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes how to keep register page data if register fails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to keep register page data if register fails" Watch "how to keep register page data if register fails" New topic
Author

how to keep register page data if register fails

Mohan Mehra
Ranch Hand

Joined: Jul 28, 2011
Posts: 70
i mean to say- now there is one register page with fields such as first name, last name,username,.... ok. so now i will fill in the details and when i click submit button and say the register fails because of similar username already exists. now the remaining fields should not clear except the username. how do we achieve that? this s my code:


register.jsp:



This is servlet class:

RegisterServlet.java:

Miku Ranjan
Ranch Hand

Joined: Oct 11, 2011
Posts: 98
Hi,
Use an ajax validation for username .
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

All form elements have a value attribute that can be used to set their initial values. You can use it to restore the submitted values to the elements.

Or, as pointed out, using Ajax to submit the values causes the original form to stay on the browser while the request is being processed in the background.

The latter is how I do a lot of form submissions, but it's a little more advanced and requires JavaScript.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mohan Mehra
Ranch Hand

Joined: Jul 28, 2011
Posts: 70
Bear Bibeault wrote:All form elements have a value attribute that can be used to set their initial values. You can use it to restore the submitted values to the elements.

.


how do i do this?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Get the values from the request and use JSP to set them into the value attributes.
Sanjeev P Kulkarni
Greenhorn

Joined: Nov 08, 2009
Posts: 20

Ajax is the best way, without sending the data to the server it will validates at the client side itself...


Sanjeev
 
 
subject: how to keep register page data if register fails
 
Similar Threads
Text Box Validation
File IO with Servlet
Data truncation: Truncated incorrect DOUBLE value:
How to transfer object from servlet tp JSP and back to Servlet
Ajax code getting null value