This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Firstly I would reccomend that you never do processing in a JSP. A servlet is a much more approriate place for that kind of activity.
Secondly, during processing, you could accumulate a list of validation error messages. If any, you could attach the list to the request as a scoped variable and forward back to the original page. The logic on the page would display the list of messages if one exists. If you wanted to get fancy, you could also associate each message with a form element by name so you could highlight the fields that failed validation using a different rendering style.
Using servelts for processing and JSP for view rendition is the best accepted practice. As a novice it would do you good to familiarize yourself with this pattern at an early stage. Look up topics such as "MVC" and "Model 2" for more details.
Session is one possible scope. Request is another. For this purpose, request scope would be the most appropriate. For any scope, you use the setAttribute method of the scope to establish a variable in that scope.
Joined: Dec 20, 2005
Request is another. For this purpose, request scope would be the most appropriate. For any scope, you use the setAttribute method of the scope to establish a variable in that scope.
To be honest, I still do not understand after you tried to explain me. It would be better if you can give me an example how to create a variable of request scope or you can point me to an appropriate tutorial...anyway thanks for your efforts..