You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jason Kemp <ja...@S1.com> on 2001/06/17 18:40:25 UTC

Implementing Struts without using a Form to call the page...

Good morning, All,

I am pretty new to Struts, and am having some problems tackling a specific
issue. I have a jsp that is being called without a form, yet does come with
some request paraemters that we'd like to check using a Struts solution.
There are numerous routes to get to this jsp, so I was hoping for a solution
that was triggered when the jsp was requested. Here are my basic questions
(and I'm sure they're quite basic, indeed):

1) How do you identify the Action class in the struts-config.xml? Or rather,
how do you specify that the Action class is to be called before the jsp on
when the jsp is requested?

2) Will the request parameters carry through the Action class to the jsp
itself? If not, how should I send that information along to the jsp?

3) Is it possible to send more information along with the request parameters
provided? If so, how?

These are probably pretty straightforward solutions for most of you, but I'm
still new in my experience with Struts and am looking for solutions and for
expanding my understanding of how Struts can be implemented. Most of my
efforts to date have produced no success, and so I am looking for any
assistance in moving past this obstacle.

Thanks In Advance,
Jason

Re: Implementing Struts without using a Form to call the page...

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

On Sun, 17 Jun 2001, Jason Kemp wrote:

> Good morning, All,
> 
> I am pretty new to Struts, and am having some problems tackling a specific
> issue. I have a jsp that is being called without a form, yet does come with
> some request paraemters that we'd like to check using a Struts solution.
> There are numerous routes to get to this jsp, so I was hoping for a solution
> that was triggered when the jsp was requested. Here are my basic questions
> (and I'm sure they're quite basic, indeed):
> 
> 1) How do you identify the Action class in the struts-config.xml? Or rather,
> how do you specify that the Action class is to be called before the jsp on
> when the jsp is requested?
> 

The Struts example application illustrates a common technique for this.

Consider the mainmenu.jsp page, and the option to "Edit your registration
information".  You will note that this links to the
"/editRegistration" action (because the hyperlink ends in ".do", it will
get mapped to the controller servlet).  This action initializes a
RegistrationForm bean with the current information, and then forwards to
the "registration.jsp" page to display it.

> 2) Will the request parameters carry through the Action class to the jsp
> itself? If not, how should I send that information along to the jsp?
> 

Yes, they do, as long as you *forward* to the page instead of redirect to
it.  For the latter case, you need to either save your information in
session scope instead, or include it all as hidden variables on the form.

> 3) Is it possible to send more information along with the request parameters
> provided? If so, how?
> 

One way is to note that if you have request parameters on the request URI
*and* in the input form, the servlet container will merge them.

> These are probably pretty straightforward solutions for most of you, but I'm
> still new in my experience with Struts and am looking for solutions and for
> expanding my understanding of how Struts can be implemented. Most of my
> efforts to date have produced no success, and so I am looking for any
> assistance in moving past this obstacle.
> 
> Thanks In Advance,
> Jason
> 

Craig