You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by rainer jünger <ju...@projektinter.net> on 2002/07/09 19:56:53 UTC

ActionServlet question

Hi,

I have a general problem in understanding a Action servlet.
Is the servelt always involved when I access the belonging URL?

e.g.:
 <action      path="/trinkwasserform"
     type="trinkwasser.TrinkwasserInputAction"
     name="trinkwasserInputForm"
     scope="session"
     input="/application/datensteckbriefe/forms/form_trinkwasser.jsp">
  <forward name="success" path="/app/trinkwasserform?todo=speichern"/>
  <forward name="preview"         path="/application/datensteckbriefe/forms/form_trinkwasser_preview.jsp"/>
 </action>

I access the *something*/trinkwasserform action. In that action I am logging a text to the serverlog. I am realy supprised that the logged text showes up only once within the log!
Isn't the Action Class always processed when I call the URL (e.g. /trinkwasserform ?)

thanks, Rainer

Re: ActionServlet question

Posted by rainer juenger <ja...@projektinter.net>.
Hi Craig,

thanks for your answere!!
I figured out the right solution!! It works now.


> I think a small example test case would be really helpful, as I'm having a
> hard time understanding what the issue is.
Of course!!

Maybe that makes it more clear:

 <action      path="/trinkwasserform"
     type="trinkwasser.TrinkwasserInputAction"
     name="trinkwasserInputForm"
     scope="session"
     input="/application/datensteckbriefe/forms/form_trinkwasser.jsp">
  <forward name="edit"
path="/application/datensteckbriefe/forms/form_trinkwasser.jsp"/>
  <forward name="preview"
path="/application/datensteckbriefe/forms/form_trinkwasser_preview.jsp"/>
  <forward name="success" path="/app/trinkwasser_portal"/>
 </action>


> For me, and for basically
> every other Struts user, the controller is invoked once per HTTP request
> that has a URL pattern mapped to the controller (i.e. things that end in
> "*.do" in the struts-example app), so I don't understand what you mean by
> "the controller only gets executed once".

Yes, now it is like that and it works so you are right ;))
I came up with my wrong conclusion since I was printing something to the
tomcat log (servlet.log("xxx");
in my Controller. There was not always an entry when I was executing it.

Rainer




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Problem in handling multipart requests

Posted by Mahesh Kumar K G <ma...@wipro.com>.
Is this a bug in Struts when forwarding from one Action class to another
?? Im using struts 1.0.1 version ..
Can anyone pls give a resolution for this error ?

javax.servlet.ServletException: Multipart data doesn't start with
boundary At
org.apache.struts.upload.DiskMultipartRequestHandler.handleRequest(DiskM
ulipartRequestHandler.java:103)

I tried using an intermediate jsp forward, it works. But Im facing some
other problems in my application, So Pls give some other solution for
this..I don't want to use an intermediate jsp forward.

Thanks

Mahesh


Re: ActionServlet question

Posted by "Craig R. McClanahan" <cr...@apache.org>.
I think a small example test case would be really helpful, as I'm having a
hard time understanding what the issue is.  For me, and for basically
every other Struts user, the controller is invoked once per HTTP request
that has a URL pattern mapped to the controller (i.e. things that end in
"*.do" in the struts-example app), so I don't understand what you mean by
"the controller only gets executed once".

Craig


On Thu, 11 Jul 2002, rainer juenger wrote:

> Date: Thu, 11 Jul 2002 19:09:47 +0200
> From: rainer juenger <ja...@projektinter.net>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: ActionServlet question
>
> Hi Craig,
>
> thanks a lot for your pations!
>
> > I think we are getting confused over terminology.  The "action servlet" is
> > configured in web.xml, not struts-config.xml <action> elements.
> You are write! I am actually not talking about the ActionServlet but about
> the Class Action that is a Servlet as well ;)
> Sorry for not beeing clear!
> I think I understood the MVC concept.
>
> Maybe it is more easy to make me understandable when I tell what I want to
> do:
> I have a form that is using Struts. So all the validation and stuff works
> just fine.
> After all required values where put in correctly the values of the form are
> beeing copied into a model bean.
> (just like in the struts-example !)
> Next step is to forward to a .jsp page (as configured in the same <action>
> <forward name="mypreview" path"/preview.jsp"/>)that gives a preview of
> inserted data. The data comes out of the model bean.
> The user has now two options: Save or Edit (Save makes the persistance).
> When clicken Edit the user is beeing sent back to the input form.
>
> I thougt all this is one action! And I need only one Controler Servlet
> (Action Class) for that. The options (Save or Edit) I wanted to give via the
> Querystring to the Controler Servlet (/app/myinputform?action=save or
> /app/myinputform?action=edit). Then the Controler Servlet would deside if
> the data should be written to the DB or the from should be shown with the
> preveously inserted values.
>
> Well, I found out that the code of the Controler Servelt is only executet
> once. And that is after I correctly filled out my form!
> When I agan call the <action path="/myinputform"> via the belonging path
> there is only the empty form an the Controler Servlet was not proccessed.
>
> could I make my selve more clear???
> If not I sort of write a documentation of my little test app.
>
> > Craig
>
> thnks a lot for your help in advanc. I guess I am having a still a problem
> in understanding how Struts works.
> Rainer
>
>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ActionServlet question

Posted by rainer juenger <ja...@projektinter.net>.
Hi Craig,

thanks a lot for your pations!

> I think we are getting confused over terminology.  The "action servlet" is
> configured in web.xml, not struts-config.xml <action> elements.
You are write! I am actually not talking about the ActionServlet but about
the Class Action that is a Servlet as well ;)
Sorry for not beeing clear!
I think I understood the MVC concept.

Maybe it is more easy to make me understandable when I tell what I want to
do:
I have a form that is using Struts. So all the validation and stuff works
just fine.
After all required values where put in correctly the values of the form are
beeing copied into a model bean.
(just like in the struts-example !)
Next step is to forward to a .jsp page (as configured in the same <action>
<forward name="mypreview" path"/preview.jsp"/>)that gives a preview of
inserted data. The data comes out of the model bean.
The user has now two options: Save or Edit (Save makes the persistance).
When clicken Edit the user is beeing sent back to the input form.

I thougt all this is one action! And I need only one Controler Servlet
(Action Class) for that. The options (Save or Edit) I wanted to give via the
Querystring to the Controler Servlet (/app/myinputform?action=save or
/app/myinputform?action=edit). Then the Controler Servlet would deside if
the data should be written to the DB or the from should be shown with the
preveously inserted values.

Well, I found out that the code of the Controler Servelt is only executet
once. And that is after I correctly filled out my form!
When I agan call the <action path="/myinputform"> via the belonging path
there is only the empty form an the Controler Servlet was not proccessed.

could I make my selve more clear???
If not I sort of write a documentation of my little test app.

> Craig

thnks a lot for your help in advanc. I guess I am having a still a problem
in understanding how Struts works.
Rainer




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ActionServlet question

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

On Wed, 10 Jul 2002, rainer juenger wrote:

> Date: Wed, 10 Jul 2002 12:08:48 +0200
> From: rainer juenger <ja...@projektinter.net>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: ActionServlet question
>
> Hi Craig,
>
>
> > It depends on how you set up your <servlet-mapping>.
> >
> > The usual practice for Struts is to use a URL pattern like "*.do", which
> > means that any URL ending with ".do" will be sent to the controller
> > servlet.  Other URLs (like one ending in "foo.jsp") will bypass the
> > controller, and go to whatever servlet is mapped for that URL instead.
> >
> > > thanks, Rainer
> > >
> >
> > Craig
>
> I am using a directory mapping rather than a extension mapping:
> /app/ is mapping to my ActionServlet.
> But that was not what I wantet to know.
> Im wondering whether the Action servlet configured in the <action/> is
> always proccessed when the servlet ist called??
>

I think we are getting confused over terminology.  The "action servlet" is
configured in web.xml, not struts-config.xml <action> elements.

If you are using path mapping ("/app/*") in your web.xml file, that means
your servlet container will send every single request that matches this
pattern to the action servlet.  Then, the action servlet looks at the part
after the "/app" to pick the <action> element to execute.

So, in general, if all of your request URLs have "/app/xxxxx" in them (and
this is the normal case for Struts applications), they will always be
processed by the controller servlet, which will always delegate to a
particular Action that you have defined.

On the other hand, if you have a hyperlink directly to a JSP page, the
controller servlet is bypassed.

> Rainer
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ActionServlet question

Posted by rainer juenger <ja...@projektinter.net>.
Hi Craig,


> It depends on how you set up your <servlet-mapping>.
>
> The usual practice for Struts is to use a URL pattern like "*.do", which
> means that any URL ending with ".do" will be sent to the controller
> servlet.  Other URLs (like one ending in "foo.jsp") will bypass the
> controller, and go to whatever servlet is mapped for that URL instead.
>
> > thanks, Rainer
> >
>
> Craig

I am using a directory mapping rather than a extension mapping:
/app/ is mapping to my ActionServlet.
But that was not what I wantet to know.
Im wondering whether the Action servlet configured in the <action/> is
always proccessed when the servlet ist called??

Rainer



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ActionServlet question

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

On Tue, 9 Jul 2002, rainer jünger wrote:

> Date: Tue, 9 Jul 2002 19:56:53 +0200
> From: rainer jünger <ju...@projektinter.net>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: ActionServlet question
>
> Hi,
>
> I have a general problem in understanding a Action servlet.
> Is the servelt always involved when I access the belonging URL?
>
> e.g.:
>  <action      path="/trinkwasserform"
>      type="trinkwasser.TrinkwasserInputAction"
>      name="trinkwasserInputForm"
>      scope="session"
>      input="/application/datensteckbriefe/forms/form_trinkwasser.jsp">
>   <forward name="success" path="/app/trinkwasserform?todo=speichern"/>
>   <forward name="preview"         path="/application/datensteckbriefe/forms/form_trinkwasser_preview.jsp"/>
>  </action>
>
> I access the *something*/trinkwasserform action. In that action I am
> logging a text to the serverlog. I am realy supprised that the logged
> text showes up only once within the log! Isn't the Action Class always
> processed when I call the URL (e.g. /trinkwasserform ?)
>

It depends on how you set up your <servlet-mapping>.

The usual practice for Struts is to use a URL pattern like "*.do", which
means that any URL ending with ".do" will be sent to the controller
servlet.  Other URLs (like one ending in "foo.jsp") will bypass the
controller, and go to whatever servlet is mapped for that URL instead.

> thanks, Rainer
>

Craig



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>