You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mindaugas Idzelis <ma...@ritvax.isc.rit.edu> on 2001/03/15 00:31:03 UTC

not rendering action attribute properly

In my JSP page, I have the following tag:

<html:form action="/logon" method="post">

when I open this page up in a browser, I get the following html

(if the first time visitin the page)
<form name="logonForm" method="post"
action=";jsessionid=aaagnMM1qx2htSNg-9Xqb9oVdkN8R">

(after a reload)
<form name="logonForm" method="post" action="">

For some reason, the action is not being rendered properly. What am I doing
wrong? Here is the relevent struts-config.xml info:

    <action    path="/logon"
               type="mysite.LogonAction"
	         name="logonForm"
               scope="session"
               validate="true"
               input="/mysite/core/loginBox.jsp">
               <forward name="needsVerification"
path="/mysite/user_activate.jsp"/>
		   <forward name="success"	path="/mysite/index.jsp"/>
    </action>

    <form-bean      name="logonForm"
                    type="mysite.core.LogonForm"/>

Any ideas what could be causing this problem? In the <%@ page directive do I
have to include the LogonForm class, etc? I am currently doing this, could
this be the problem? Thank you.


Multiple bean on a JSP file

Posted by Nguyen Thanh Phong <ph...@sdcgrp.com>.
Hi all,

Is it possible for me to declare two or more beans on the JSP files that use
struts framework. I want to split input from the user into many beans but
don't want to provide an extra bean to capture all input and perform
splitting work in the Action.

Thanks.

Nguyen Thanh Phong                           Tel: 84-8-837 25 06/837 25 07
Saigon Software Development Company (SDC)    Fax: 84-8-837 25 11
10 Co Giang Street, Dist I, HCMC             Email:
phong.nguyen_thanh@sdcgrp.com
Vietnam


RE: not rendering action attribute properly (Found problem)

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 15 Mar 2001, Mindaugas Idzelis wrote:

> I found the problem. It was in my web.xml file. I had the following:
> 
>         <servlet-mapping>
>                 <servlet-name>action</servlet-name>
>                 <url-pattern>*.do</url-pattern>
> 		    <servlet-name>action</servlet-name>
> 		    <url-pattern>/mysite<url-pattern>
>         </servlet-mapping>
> 
> I guess when struts was looking up to see what to add to the end of the
> servlets name there was a problem. (I guess it's looking to see which url
> patterns match "action" and since I have two patterns it got confused and
> outputed nothing.
> 

You are correct in your thought that Struts looks at the <servlet-mapping>
to determine how to construct the submit URLs in <html:form>.  The problem
is that Struts would read the above and assume that the "*.do" pattern was
the correct one.  However, Tomcat 3.2.1 (at least) would parse that and
use the "/mysite" pattern (which you would really want to be
"/mysite/*") instead.

Running this on a servlet container that uses a validating XML parser to
read the web.xml file (such as Tomcat 4.0) would have caught this problem,
because it would have refused to load the web app in the first place.

> Would this be considered a bug, or is there something wrong with my web.xml
> file? What I was trying to accomplish was to have the action servlet handle
> the initial request to the website. Thanks.
> 

Well, you've got an invalid web.xml file all right.  The technical term
for what happens next is "undefined behavior".  :-)

Craig


RE: not rendering action attribute properly (Found problem)

Posted by Mindaugas Idzelis <ma...@ritvax.isc.rit.edu>.
I found the problem. It was in my web.xml file. I had the following:

        <servlet-mapping>
                <servlet-name>action</servlet-name>
                <url-pattern>*.do</url-pattern>
		    <servlet-name>action</servlet-name>
		    <url-pattern>/mysite<url-pattern>
        </servlet-mapping>

I guess when struts was looking up to see what to add to the end of the
servlets name there was a problem. (I guess it's looking to see which url
patterns match "action" and since I have two patterns it got confused and
outputed nothing.

Would this be considered a bug, or is there something wrong with my web.xml
file? What I was trying to accomplish was to have the action servlet handle
the initial request to the website. Thanks.

-----Original Message-----
From: Mindaugas Idzelis [mailto:mai3116@ritvax.isc.rit.edu]
Sent: Wednesday, March 14, 2001 10:45 PM
To: struts-user@jakarta.apache.org
Subject: RE: <html:form> not rendering action attribute properly


Yes, I am using the "struts-example" struts-config.xml file as my base
config file. I have the action servlet loaded on startup: (When I start the
servlet engine, i see all the debug messages fly buy) all the formBeans are
properly found. There is no output in the log file about any errors. There
are no exceptions.

Yes, the struts example works for me. I'm currently trying to compare as
much of my code to its code as possible.

--min




RE: not rendering action attribute properly

Posted by Mindaugas Idzelis <ma...@ritvax.isc.rit.edu>.
Yes, I am using the "struts-example" struts-config.xml file as my base
config file. I have the action servlet loaded on startup: (When I start the
servlet engine, i see all the debug messages fly buy) all the formBeans are
properly found. There is no output in the log file about any errors. There
are no exceptions.

Yes, the struts example works for me. I'm currently trying to compare as
much of my code to its code as possible.

--min


On Wed, 14 Mar 2001, Mindaugas Idzelis wrote:

> Well... yes, I know why the sessionid was there the first time and not the
> next. It tried to use url rewriting first, and cookies second. My problem
is
> the actual action="". This should be action="/logon.do" Any ideas???
>

One thing that would cause problems here is if you forget to configure
your controller servlet for <load-on-startup> (or your servlet container
does not implement this correctly).  The <html:form> tag depends on the
controller servlet having actually been initialized (although it doesn't
matter whether a request has gone through it yet) in order to set things
up correctly.

Does the Struts example work for you?

> --min
>

Craig


RE: not rendering action attribute properly

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 14 Mar 2001, Mindaugas Idzelis wrote:

> Well... yes, I know why the sessionid was there the first time and not the
> next. It tried to use url rewriting first, and cookies second. My problem is
> the actual action="". This should be action="/logon.do" Any ideas???
> 

One thing that would cause problems here is if you forget to configure
your controller servlet for <load-on-startup> (or your servlet container
does not implement this correctly).  The <html:form> tag depends on the
controller servlet having actually been initialized (although it doesn't
matter whether a request has gone through it yet) in order to set things
up correctly.

Does the Struts example work for you?

> --min
> 

Craig


RE: not rendering action attribute properly

Posted by Mindaugas Idzelis <ma...@ritvax.isc.rit.edu>.
Well... yes, I know why the sessionid was there the first time and not the
next. It tried to use url rewriting first, and cookies second. My problem is
the actual action="". This should be action="/logon.do" Any ideas???

--min

-----Original Message-----
From: Jeff Davis [mailto:jeffd@bioObjects.com]
Sent: Wednesday, March 14, 2001 6:46 PM
To: struts-user@jakarta.apache.org
Subject: Re: <html:form> not rendering action attribute properly


At least under WebLogic, when you first visit a page under a certain context
or web site, the WL server doesn't know whether the user's browser supports
cookies or not. As a consequence, it uses URL rewritting the first time
through (this can be turned off, in the case of WL, in the weblogic.xml
settings file). Subsequent visits to the page use cookies instead. I had the
same problem with the <html:img> tag (and the image wasn't being loaded
properly as a result).

jeff
----- Original Message -----
From: "Mindaugas Idzelis" <ma...@ritvax.isc.rit.edu>
To: "struts" <st...@jakarta.apache.org>
Sent: Wednesday, March 14, 2001 3:31 PM
Subject: <html:form> not rendering action attribute properly


> In my JSP page, I have the following tag:
>
> <html:form action="/logon" method="post">
>
> when I open this page up in a browser, I get the following html
>
> (if the first time visitin the page)
> <form name="logonForm" method="post"
> action=";jsessionid=aaagnMM1qx2htSNg-9Xqb9oVdkN8R">
>
> (after a reload)
> <form name="logonForm" method="post" action="">
>
> For some reason, the action is not being rendered properly. What am I
doing
> wrong? Here is the relevent struts-config.xml info:
>
>     <action    path="/logon"
>                type="mysite.LogonAction"
>          name="logonForm"
>                scope="session"
>                validate="true"
>                input="/mysite/core/loginBox.jsp">
>                <forward name="needsVerification"
> path="/mysite/user_activate.jsp"/>
>    <forward name="success" path="/mysite/index.jsp"/>
>     </action>
>
>     <form-bean      name="logonForm"
>                     type="mysite.core.LogonForm"/>
>
> Any ideas what could be causing this problem? In the <%@ page directive do
I
> have to include the LogonForm class, etc? I am currently doing this, could
> this be the problem? Thank you.
>
>


Re: not rendering action attribute properly

Posted by Jeff Davis <je...@bioObjects.com>.
At least under WebLogic, when you first visit a page under a certain context
or web site, the WL server doesn't know whether the user's browser supports
cookies or not. As a consequence, it uses URL rewritting the first time
through (this can be turned off, in the case of WL, in the weblogic.xml
settings file). Subsequent visits to the page use cookies instead. I had the
same problem with the <html:img> tag (and the image wasn't being loaded
properly as a result).

jeff
----- Original Message -----
From: "Mindaugas Idzelis" <ma...@ritvax.isc.rit.edu>
To: "struts" <st...@jakarta.apache.org>
Sent: Wednesday, March 14, 2001 3:31 PM
Subject: <html:form> not rendering action attribute properly


> In my JSP page, I have the following tag:
>
> <html:form action="/logon" method="post">
>
> when I open this page up in a browser, I get the following html
>
> (if the first time visitin the page)
> <form name="logonForm" method="post"
> action=";jsessionid=aaagnMM1qx2htSNg-9Xqb9oVdkN8R">
>
> (after a reload)
> <form name="logonForm" method="post" action="">
>
> For some reason, the action is not being rendered properly. What am I
doing
> wrong? Here is the relevent struts-config.xml info:
>
>     <action    path="/logon"
>                type="mysite.LogonAction"
>          name="logonForm"
>                scope="session"
>                validate="true"
>                input="/mysite/core/loginBox.jsp">
>                <forward name="needsVerification"
> path="/mysite/user_activate.jsp"/>
>    <forward name="success" path="/mysite/index.jsp"/>
>     </action>
>
>     <form-bean      name="logonForm"
>                     type="mysite.core.LogonForm"/>
>
> Any ideas what could be causing this problem? In the <%@ page directive do
I
> have to include the LogonForm class, etc? I am currently doing this, could
> this be the problem? Thank you.
>
>