• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can a EL expression pass a value that was entered into a form?

 
John Piper
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
  •  
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64959
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    If you can't answer the questions, read this article and try again.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64959
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    And (personal pet peeve): name="un". un? Use real words and keep things readable.
     
    Stefan Evans
    Bartender
    Posts: 1744
    10
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Pie
    Posts: 64959
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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...
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic