Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Struts 1: How to access Struts form data in JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 1: How to access Struts form data in JavaScript" Watch "Struts 1: How to access Struts form data in JavaScript" New topic
Author

Struts 1: How to access Struts form data in JavaScript

Omi Kir
Greenhorn

Joined: Nov 05, 2008
Posts: 3
Hi.

I need to access Struts form data in my JavaScript via JSP. Plese let me know if there is any standard way to do this.

I also need to access the request variables (set via request.setAttribute(..,..)) in my JSP which are set in Struts form. I am open to use Struts tags or Scriplets but I prefer to use standard Struts Tags in my JSP.

Please suggest me a standard procedure to achieve both.

Thank you.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

Originally posted by Omi Kir:
I need to access Struts form data in my JavaScript via JSP. Plese let me know if there is any standard way to do this.

Yes. You write out JavaScript variables containing the data in your JSP. For example:
var myData = '<bean:write name="commaDelmitedListOfData" />';


I also need to access the request variables (set via request.setAttribute(..,..)) in my JSP which are set in Struts form. I am open to use Struts tags or Scriplets but I prefer to use standard Struts Tags in my JSP.
What
What kind of variables? If they are strings you can use bean efine. Otherwise, you can use jsp:useBean. Scriptlets should be a last resort for new code.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 1: How to access Struts form data in JavaScript