You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Winters, Jason" <jw...@Inst.StrykerCorp.Com> on 2001/01/30 23:08:57 UTC

Setting initial page to be an action

I'm trying to setup my application so that the initial page is an action.
When the user enters a URL like this, http://server/myapp they should be
sent to http://server/myapp/index.do.  At the moment, they get forwarded to
http://server/myapp/index.jsp which crashes because stuff that was setup in
the index action does not exist.

Any ideas on how to accomplish this would be greatly appreciated!

Jason Winters


Re: Setting initial page to be an action

Posted by renzo estrella <re...@yahoo.com>.
I tried this a couple of days ago but the results
 back where a directly listing. I also had to add
 an entry in my action.xml to handle "index" action
 but it still returned the directory listing.
While specifying index.do does give the correct
result.
Perhaps this behavior is due to weblogic5.1 ?

--- "Craig R. McClanahan"
<Cr...@eng.sun.com> wrote:
> "Winters, Jason" wrote:
> 
> > I'm trying to setup my application so that the
> initial page is an action.
> > When the user enters a URL like this,
> http://server/myapp they should be
> > sent to http://server/myapp/index.do.  At the
> moment, they get forwarded to
> > http://server/myapp/index.jsp which crashes
> because stuff that was setup in
> > the index action does not exist.
> >
> 
> In your web.xml file, you can define a "welcome
> file" that is used by the
> servlet container (that's how it knows to try
> index.html or index.jsp).  So,
> you could add something like this:
> 
>     <welcome-file-list>
>         <welcome-file>index.do</welcome-file>
>     </welcome-file-list>
> 
> One thing to note is that your index.do method will
> get called for any
> "directory name" within the app as well.
> 
> >
> > Any ideas on how to accomplish this would be
> greatly appreciated!
> >
> > Jason Winters
> 
> Craig McClanahan
> 
> 


__________________________________________________
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

Re: Setting initial page to be an action

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"Winters, Jason" wrote:

> I'm trying to setup my application so that the initial page is an action.
> When the user enters a URL like this, http://server/myapp they should be
> sent to http://server/myapp/index.do.  At the moment, they get forwarded to
> http://server/myapp/index.jsp which crashes because stuff that was setup in
> the index action does not exist.
>

In your web.xml file, you can define a "welcome file" that is used by the
servlet container (that's how it knows to try index.html or index.jsp).  So,
you could add something like this:

    <welcome-file-list>
        <welcome-file>index.do</welcome-file>
    </welcome-file-list>

One thing to note is that your index.do method will get called for any
"directory name" within the app as well.

>
> Any ideas on how to accomplish this would be greatly appreciated!
>
> Jason Winters

Craig McClanahan



Re: Setting initial page to be an action

Posted by Mishkin Berteig <mi...@berteig.com>.
You can create an index.html file which contains something like this:

<html>
<head>
<meta http-equiv="Refresh" content="0; url=/frontpage.do">
<script>
window.location.href="/frontpage.do";
</script>
</head>
<body>
</body>
</body>

which works for both javascript and non-javascript browsers.
This is what we use on our system.

Regards,
Mishkin.

"Winters, Jason" wrote:

> I'm trying to setup my application so that the initial page is an action.
> When the user enters a URL like this, http://server/myapp they should be
> sent to http://server/myapp/index.do.  At the moment, they get forwarded to
> http://server/myapp/index.jsp which crashes because stuff that was setup in
> the index action does not exist.
>
> Any ideas on how to accomplish this would be greatly appreciated!
>
> Jason Winters

Re: Setting initial page to be an action

Posted by Ted Husted <ne...@husted.com>.
If a JSP requires something created by an action, you can test for it
first, and then forward to the action if it is missing, e.g. 

<logic:notPresent name="myIndexBean"><logic:redirect
href="index.do"/></logic:notPresent>

I usually put these after the taglib declarations, but before the HTML.

*********** REPLY SEPARATOR  ***********

On 1/30/2001 at 5:08 PM Winters, Jason wrote:

I'm trying to setup my application so that the initial page is an
action.
When the user enters a URL like this, http://server/myapp they should
be
sent to http://server/myapp/index.do.  At the moment, they get
forwarded to
http://server/myapp/index.jsp which crashes because stuff that was
setup in
the index action does not exist.

Any ideas on how to accomplish this would be greatly appreciated!

Jason Winters



-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 425-0252; Fax 716 223-2506.
-- http://www.husted.com/about/struts/