Why we shouldn't/can't pick request parameters passed from client inside jsp?
Vineet Kumar Garg
Greenhorn
Joined: Apr 11, 2012
Posts: 21
posted
0
After forwarding a request to a jsp from controller servlet --- Why we shouldn't/can't pick request parameters passed from client inside jsp?
- why it's recommended to have the data set as attributes and then use it in JSP?
Vineet Kumar Garg wrote:After forwarding a request to a jsp from controller servlet
--- Why we shouldn't/can't pick request parameters passed from client inside jsp?
It depends if the same submitted request is being used. If so, then the parameters are still present. If you are using the PRG pattern, which is almost always appropriate, then the parameters are no longer present.
- why it's recommended to have the data set as attributes and then use it in JSP?
Again it depends on the data. Scoped variables (what you are calling attributes) are the most versatile way to convey data from the controller to the JSP.
I played a bit more with JSP and found out that all JSP parameters are visible inside jsp as well as it was same object passed from servlet. ( makes sense.)
Now only question is about best practice .. why we shouldn't use parameters from request object inside jsp?
It's not necessarily a bad practice in itself, but why you may have heard that it's not a good practice is because it may be the result of following something that is a bad practice: submitting a form to a JSP rather than a task controller.
See the article I linked to for more information.
Vineet Kumar Garg
Greenhorn
Joined: Apr 11, 2012
Posts: 21
posted
0
Thanks Bear. Really nice article.
I got the idea. Will be pinging you more on the way to certification of OCEJWCD :)