• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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.
 
Marshal
Posts: 67420
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
    Marshal
    Posts: 67420
    173
    Mac Mac OS X IntelliJ IDE jQuery Java
    • 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
    Marshal
    Posts: 67420
    173
    Mac Mac OS X IntelliJ IDE jQuery Java
    • 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.
     
    Bartender
    Posts: 1845
    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
    Marshal
    Posts: 67420
    173
    Mac Mac OS X IntelliJ IDE jQuery Java
    • 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...
     
    Let me tell you a story about a man named Jed. He made this tiny ad:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
      Bookmark Topic Watch Topic
    • New Topic