Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting an attribute from a JSP  RSS feed

 
alex seba
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
 
Med Shabe
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi alex,
You can process the form elements like this adn I'm sure many more other ways:
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
arnold yan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!