You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Perry Jeung <pj...@yahoo.com> on 2005/12/12 07:42:27 UTC

html:form dynamic action value

I have a html:form tag with a dynamic action value that works in one version of
Struts and not in another.

I'm new to Tiles and I want to do the following in one of the reusable tiles
named report.jsp:

<html:form action="<%= (String)request.getAttribute("action") %>" >

In an experiment, I took the struts-example webapp from the Struts 1.2.8 binary
distributon and modified the html-link.jsp like this:

<%
	String actionValue = "/html-link-submit";
	request.setAttribute("action", actionValue);
%>
    <html:form action="<%= (String)request.getAttribute("action") %>">


This works so I go back to my application to do the same thing
but doesn't work.  I get the following error on the html page in the browser:
[ServletException in:/tiles/report.jsp] null'

I'm using a debugger and I can see that the action attribute is defined in the
request context.

Why the difference?  Is it the struts environment?

Both are running on Tomcat 5.0.28.

My app uses Struts 1.1 and has this preamble in web.xml

<!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
  "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

The modified struts-example is from Struts 1.2.8 and has the same web.xml
preamble as above.

Would I be right in concluding that the difference is in the Struts version and
that upgrading would solve my problem?
My app has close to 100 pages, so before I start, can anybody offer some
insight as to the root of the problem.

Thanks.

Perry Jeung


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html:form dynamic action value

Posted by Laurie Harper <la...@holoweb.net>.
Perry Jeung wrote:
> I have a html:form tag with a dynamic action value that works in one version of
> Struts and not in another.
> 
> I'm new to Tiles and I want to do the following in one of the reusable tiles
> named report.jsp:
> 
> <html:form action="<%= (String)request.getAttribute("action") %>" >
> 
> In an experiment, I took the struts-example webapp from the Struts 1.2.8 binary
> distributon and modified the html-link.jsp like this:
> 
> <%
> 	String actionValue = "/html-link-submit";
> 	request.setAttribute("action", actionValue);
> %>
>     <html:form action="<%= (String)request.getAttribute("action") %>">
> 
> 
> This works so I go back to my application to do the same thing
> but doesn't work.  I get the following error on the html page in the browser:
> [ServletException in:/tiles/report.jsp] null'
> 
> I'm using a debugger and I can see that the action attribute is defined in the
> request context.
> 
> Why the difference?  Is it the struts environment?
> 
> Both are running on Tomcat 5.0.28.
> 
> My app uses Struts 1.1 and has this preamble in web.xml
> 
> <!DOCTYPE web-app
>   PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
>   "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
> 
> The modified struts-example is from Struts 1.2.8 and has the same web.xml
> preamble as above.
> 
> Would I be right in concluding that the difference is in the Struts version and
> that upgrading would solve my problem?
> My app has close to 100 pages, so before I start, can anybody offer some
> insight as to the root of the problem.

Have you tried your experiment using the examples app from Struts 1.1? 
That might be a useful sanity check before drawing any conclusions. I 
can't offer any insight into the error you're getting without seeing the 
full stacktrace (if then! :-)

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org