Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 1: How to access Struts form data in JavaScript

 
Omi Kir
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic