This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes form submission using struts link tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "form submission using struts link tag" Watch "form submission using struts link tag" New topic
Author

form submission using struts link tag

dnyan ginde
Ranch Hand

Joined: Jan 17, 2006
Posts: 68
Hello,

Can anybody please tell me how can i submit a form using <html:link>. I want to send multiple parameters with this submission.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In order to submit a form from a link, you need to use javascript to:

1) change the form's action to the URI you want the link to go to
2) submit the form.

If you're doing this, I'd recommend using a regular <a> tag, rather than <html:link>.

Here's a simple example:

<a href="#" onklick="document.myForm.action='myAction.do';document.myForm.form.submit();">Click Here</a>

onklick is deliberately misspelled to get this message past the security measures at JavaRanch.


Merrill
Consultant, Sima Solutions
dnyan ginde
Ranch Hand

Joined: Jan 17, 2006
Posts: 68
Merrill I am using javascript to submit the form. My code is as follows

When i am using the above code i get the following exception
[1/30/06 18:51:51:336 IST] 64d7befc WebGroup E SRVE0026E: [Servlet Error]-[/pages/details.jsp(32,66) Attribute lForm has no value]: org.apache.jasper.compiler.ParseException: /pages/details.jsp(32,66) Attribute lForm has no value.

But when i use the normal <a> tag it works. Even you suggested to use <a> instead of <html:link>. Any specific reason its not working with <html:link>?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The reason it doesn't work with <html:link> is that you can't embed a <bean:write> tag inside any <html:xxx> tag. Struts just doesn't support it. If you really wanted to use an <html:link> tag, you could use a scriptlet in the href attribute.

In my opinion, <html:link> doesn't really give you any advantages over <a> when you're doing this type of thing, so why use it?
dnyan ginde
Ranch Hand

Joined: Jan 17, 2006
Posts: 68
Thanks for the post.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: form submission using struts link tag