| Author |
Can a EL expression pass a value that was entered into a form?
|
John Piper
Greenhorn
Joined: Mar 27, 2011
Posts: 12
|
|
After listening to Bear's suggestion I'm tossing my previous code and am trying to write code using JSTL and EL.
What I am trying to accomplish currently is implementing session tracking. I just want to track the username used to login to a form and pass it from page to page as the user navigates the website.
I have a very simple two jsp pages setup to try to figure out how to pass what is input in the username field in the form.
index.jsp
securitycheck.jsp
Is what I'm trying to do possible? And if so, how?
Thanks everyone.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56233
|
|
Looking at this code:
Let's see if I can help you answer your own question. Answer these questions:
When does the <c:set> get executed?When does the user enter the value into the field?How does this answer your question?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56233
|
|
|
If you can't answer the questions, read this article and try again.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56233
|
|
|
And (personal pet peeve): name="un". un? Use real words and keep things readable.
|
 |
Stefan Evans
Bartender
Joined: Jul 06, 2005
Posts: 1005
|
|
One more tidbit of information that may help.
EL defines an implicit variable called "param"
"param" is a map of all the request parameters, keyed by request parameter name.
${param.foo} is approximately equivalent to request.getParameter("foo");
I actually think you're taking Bear a little TOO literally.
Yes you want to stop scriptlets in the JSP, and use EL.
But you also want to use Java beans to encapsulate most of your data
So rather than having a <c:set> on the page I would go with creating a User Bean (java class) and populate that with values from the request parameters.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56233
|
|
Stefan Evans wrote:
So rather than having a <c:set> on the page I would go with creating a User Bean (java class) and populate that with values from the request parameters.
I'd go as far as to say that collecting params isn't something that belongs in a JSP at all. But one thing at a time...
|
 |
 |
|
|
subject: Can a EL expression pass a value that was entered into a form?
|
|
|