Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I call setParameter in a request object?

Tags:

java

jsp

jstl

This is probably due to my misunderstanding and incomplete information of JSP and JSTL. I have a web page where I have input elements such as

<input name="elementID" value="${param.elementID}"/>

When I am trying to save the form, I check for that elementID and other elements to conform to certain constraints "numeric, less than XXX". I show an error message if they don't. All the parameters are saved and user does not need to type it again after fixing the error.

After saved, when I am redirecting to the same page for the object to be edited, I am looking a way to set the parameter like request.setParameter("elementID",..) Is there a way to do this ? However the only thing I can find is request.setAttribute.

like image 731
Ender Wiggin Avatar asked Jul 17 '26 08:07

Ender Wiggin


1 Answers

HTTP responses does not support passing parameters.
JSP/Servelets allows you to either use request.setAttribute or session.setAttribute for that purpose. Both methods are available when processing the page you're redirecting to, So basically, you got it right...

Also, from what you describe, you may want to check client-side validation: don't submit the form until you're validating it using client-side scripting (javascript)

like image 88
Aviram Avatar answered Jul 18 '26 21:07

Aviram



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!