You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andy Engle <st...@andyengle.com> on 2004/02/13 18:10:45 UTC

Calling JSPs directly

Hi all,

I'm working with a web application in which I have multiple pages of
information, currently located in PHP files.  I want to convert these
PHP files into JSPs, and then make them available to be directly called
within my web application. I would like to have these JSPs available
for direct access because I want to make it easy for users of this
application to bookmarks whatever pages they're interested in going
back to from time to time. Each page will have a form, which will be
submitted to a Struts action when submitted, and then from there I want
the action to update the database, then return the same, updated JSP to
the user.

I'm wondering if making JSPs available to the user in this manner is a
poor practice, and if so, what would be a better way of doing it? 
Furthermore, will I run into any problems with the Struts custom tags
or tiles by taking this approach?

Thanks very much for sharing your thoughts.


Andy


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


Re: Calling JSPs directly

Posted by Christian Bollmeyer <ja...@christianbollmeyer.de>.
On Friday 13 February 2004 18:10, Andy Engle wrote:
> Hi all,

Hi Andy,

> I'm working with a web application in which I have multiple pages of
> information, currently located in PHP files.  I want to convert these
> PHP files into JSPs, and then make them available to be directly
> called within my web application. I would like to have these JSPs
> available for direct access because I want to make it easy for users
> of this application to bookmarks whatever pages they're interested in
> going back to from time to time.

Well, you can bookmark Struts actions as well. Generally, I consider
direct calls to JSP pages a bad design. It's better to wrap such
pages into an Action (you can use the standard ForwardAction,
just a single line in struts-config.xml) and change the links to
calling that instead of the 'real' page behind it. The advantage
of this approach is that - though it might seem to be a little
more work at the beginning - you have everything centralized.
That means: one single point of handling security issues if
needed, and if you want to change the application structure
later (which will inevitably be the case one day, and that
day is *always* nearer than one thinks it is) or just want
to replace some files, port everything to Tiles (recommendable)
or whatever, you only have to deal with struts-config.xml
and tiles-defs.xml, possibly, but not with hundreds of links
in each and every file.  

> Each page will have a form, which 
> will be submitted to a Struts action when submitted, and then from
> there I want the action to update the database, then return the same,
> updated JSP to the user.

So you set up a standard ForwardAction that forwards to
your JSP; if you want to pre-populate some fields, write
a small custom Action that creates the form bean and
puts it into the appropriate scope before forwarding, and
that's it.

> I'm wondering if making JSPs available to the user in this manner is
> a poor practice, and if so, what would be a better way of doing it?
> Furthermore, will I run into any problems with the Struts custom tags
> or tiles by taking this approach?

See above. In particular when thinking about Tiles,
use Action references in your links from the very
beginning. Then, you can gradually port your
site to Tiles step-by-step (replacing the Action
targets by Tiles definitions, while the JSPs still
call the Actions and can't tell whether the target
is a normal JSP page or a Tiles definition), and
it will still work as usual during the entire 
migration process.

> Thanks very much for sharing your thoughts.
>
>
> Andy

HTH,
-- Chris.

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


RE: Calling JSPs directly

Posted by Andy Engle <st...@andyengle.com>.
Hi all,

Thanks for sharing your thoughts about my question from earlier today. 
I am going to heed your advice and go ahead with accessing my JSPs
through actions.  You've given me some new ideas on how I can make my
application better, which I appreciate.

<off-topic>And I'm glad that I finally found some decent Valentine's
Day gifts for my wife for our first married Valentine's
Day.</off-topic>

Take care and thanks again.


Andy


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


RE: Calling JSPs directly

Posted by Robert Nocera <rn...@neosllc.com>.
Andy,

Depending on the complexity of the application, you may want to consider
having the user call an action first, not a jsp.  The action can do any
setup for the jsp page, such as retrieving any collections you may need to
populate dropdown lists in the page.  Even if the action does nothing right
now, if wanted to add that type of functionality later or other
functionality that would require an action beforehand, the users would not
need to change their bookmarks.

-Rob


-----Original Message-----
From: Andy Engle [mailto:struts@andyengle.com] 
Sent: Friday, February 13, 2004 12:11 PM
To: struts-user@jakarta.apache.org
Subject: Calling JSPs directly

Hi all,

I'm working with a web application in which I have multiple pages of
information, currently located in PHP files.  I want to convert these
PHP files into JSPs, and then make them available to be directly called
within my web application. I would like to have these JSPs available
for direct access because I want to make it easy for users of this
application to bookmarks whatever pages they're interested in going
back to from time to time. Each page will have a form, which will be
submitted to a Struts action when submitted, and then from there I want
the action to update the database, then return the same, updated JSP to
the user.

I'm wondering if making JSPs available to the user in this manner is a
poor practice, and if so, what would be a better way of doing it? 
Furthermore, will I run into any problems with the Struts custom tags
or tiles by taking this approach?

Thanks very much for sharing your thoughts.


Andy


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


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