• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting an attribute from a JSP

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
sorry for this simple question but I'm a real greenhorn in JSP and just learning, so I think I'm just at the right place here...
How can I pass an attribute value from the JSP to a class method as a parameter?
For example: In a line like <% myClass.doSomething( parameter) %>, I want the parameter to be a value from the page (e.g. document.form.element.value)
This can't be to difficult?
Thanks
Alex
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi alex,
You can process the form elements like this adn I'm sure many more other ways:
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use set/getAttributes of the various implicit objects. For example, for the implicit request object:


The JSP syntax reference is available here. http://www.jspin.com/ is also a pretty good resource.
 
alex seba
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
thank you both for your help! But I still have my problem. I do not need the attributes in a servlet from a HttpServletRequest, but directly in a JSP-file in a scriptlet.
Anthony, in your example, this would mean not to set a String like "hello" as a value, but to set something like document.form.element.value. So, my question is, how do I get the attributes inside a scriptlet? Or is there a possibility to know a JavaScript variable inside a scriptlet?
Thanks
Alex
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't think of a way to do this in the same page, since the scriplets are already executed by the time the page is loaded. How can you pass a parameter to a method after the method is already executed?
Arnold
 
reply
    Bookmark Topic Watch Topic
  • New Topic