You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by mitalub <mi...@yahoo.com> on 2009/03/09 02:31:43 UTC

Default Tomcat Page w/o Redirect

Hi,

I've tried searching around for this, but I can't find a clear answer, so am
starting to think it's not possible.

Currently, my home page is at http://www.mydomain.com/myappname/app/home.

I want to be able to access this page by going to just
http://www.mydomain.com, but without a redirect.  In other words, the
address in the address bar should remain short & sweet.  Is this possible
with tomcat?  

Thanks.
-- 
View this message in context: http://www.nabble.com/Default-Tomcat-Page-w-o-Redirect-tp22405664p22405664.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Default Tomcat Page w/o Redirect

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: mitalub [mailto:mitalub@yahoo.com] 
> Subject: RE: Default Tomcat Page w/o Redirect
> 
> Setting the welcome page seems to work for static 
> welcome pages only... 

Not true, you may specify dynamic content, such as index.jsp.

Since Spring is doing most of the dirty work for you, try just changing the webapp name to ROOT, and see what happens.  As long as the servlet mapping is correct in WEB-INF/web.xml, that may be all you need.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Ken Bowen <kb...@als.com>.
On Mar 9, 2009, at 4:46 PM, Len Popp wrote:

> So, I'm a disciplined developer? :-)
>

I think it'd be a pretty good bet on this list :-)

> Yeah, it's basically because in this setup the JSP pages are part of
> the app's implementation, not part of the exposed URL space. So I put
> them under WEB-INF with the classes, libs, tags, etc. Practically
> speaking the effect of allowing user access to the JSPs would be that
> you could enter a bogus URL and get a garbage page (probably a 500
> error).

Well, I'm really only being curmudgeonly.  It's true that /some/ users  
will always poke around and get into trouble, even when the app is  
well organized along mvc lines.  From a traffic/business point of  
view, it's best to minimize that trouble....hmm...have to think about  
one of those projects of mine.

Cheers,
Ken

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Len Popp <le...@gmail.com>.
On Mon, Mar 9, 2009 at 16:03, Ken Bowen <kb...@als.com> wrote:
> I agree with everything in both posts, but I just don't see what the
> /location/ of the jsp files (inside/outside WEB-INF) has to do with it.
> All that controls is whether a user/client can find a way to look inside the
> file.
> One can (as I do) follow the separation of concerns quite strictly (app
> logic in java files; presentation in jsp files), and have those
> jsp files residing in something like webapps/app/pages, while the classes of
> course normally reside in webapps/app/WEB-INF/classes.
> And I'm sure we could find (in the wild out there, not developed by anyone
> here) JSP pages residing under WEB-INF which were
> horribly encrusted with java code and application logic.
>
> It's more a matter of developer discipline than anything else.

So, I'm a disciplined developer? :-)

Yeah, it's basically because in this setup the JSP pages are part of
the app's implementation, not part of the exposed URL space. So I put
them under WEB-INF with the classes, libs, tags, etc. Practically
speaking the effect of allowing user access to the JSPs would be that
you could enter a bogus URL and get a garbage page (probably a 500
error).
-- 
Len

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ken,

On 3/9/2009 4:03 PM, Ken Bowen wrote:
> I agree with everything in both posts, but I just don't see what the
> /location/ of the jsp files (inside/outside WEB-INF) has to do with it.

It's just an access thing, really: no remote client can request that a
JSP be run without it's handling servlet running first. Just because you
shouldn't poke a fire doesn't mean you won't.

It's not about revealing code (which is another matter altogether), it's
about controlling access to the execution of your JSPs. If your JSPs are
within WEB-INF, no client can access them directly for any reason. That
forces the developers to code their application in such a way as to
support that setup.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkm4M1UACgkQ9CaO5/Lv0PA2KgCfdGBUAmy8yI8waI6cbeziHE7I
Fn0AoIuKuK4GtTgtTh5RaCKTtVGpRde7
=TmDB
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Ken Bowen <kb...@als.com>.
I agree with everything in both posts, but I just don't see what the / 
location/ of the jsp files (inside/outside WEB-INF) has to do with it.
All that controls is whether a user/client can find a way to look  
inside the file.
One can (as I do) follow the separation of concerns quite strictly  
(app logic in java files; presentation in jsp files), and have those
jsp files residing in something like webapps/app/pages, while the  
classes of course normally reside in webapps/app/WEB-INF/classes.
And I'm sure we could find (in the wild out there, not developed by  
anyone here) JSP pages residing under WEB-INF which were
horribly encrusted with java code and application logic.

It's more a matter of developer discipline than anything else.

....my 2 bits...Ken

On Mar 9, 2009, at 3:49 PM, Hassan Schroeder wrote:

> On Mon, Mar 9, 2009 at 12:23 PM, Len Popp <le...@gmail.com> wrote:
>> What I mean is, clients *never* access a .jsp file by URL, e.g.
>> "http://www.example.com/app/foo.jsp". All URLs seen by the client are
>> mapped to servlets, not JSP files.
>
>> The reason for doing it this way is to separate app logic from page
>> layout. I find it difficult to code a substantial app by mixing Java
>> code into JSP pages, and it's lots easier to modify the format of a
>> web page if the app logic isn't all tangled up in it.
>
> +1 on that approach, makes life a whole lot easier.
>
> Besides being MVC, it goes along with Tim B-L's classic stance that
> "cool urls don't change" -- don't reveal the technology being used by
> using a file suffix that you may later want/need to change...
>
> -- 
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Hassan Schroeder <ha...@gmail.com>.
On Mon, Mar 9, 2009 at 12:23 PM, Len Popp <le...@gmail.com> wrote:
> What I mean is, clients *never* access a .jsp file by URL, e.g.
> "http://www.example.com/app/foo.jsp". All URLs seen by the client are
> mapped to servlets, not JSP files.

> The reason for doing it this way is to separate app logic from page
> layout. I find it difficult to code a substantial app by mixing Java
> code into JSP pages, and it's lots easier to modify the format of a
> web page if the app logic isn't all tangled up in it.

+1 on that approach, makes life a whole lot easier.

Besides being MVC, it goes along with Tim B-L's classic stance that
"cool urls don't change" -- don't reveal the technology being used by
using a file suffix that you may later want/need to change...

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Gregor Schneider <rc...@googlemail.com>.
No I got it.

Guess I'll spent some time of the coming weekend reading up those concepts.

Cheers

Gregor
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Len Popp <le...@gmail.com>.
On Mon, Mar 9, 2009 at 15:58, Gregor Schneider <rc...@googlemail.com> wrote:
> Len,
>
> agreed to the most of what you said, however, I still do not see why
> JSPs have to go (or should go) into WEB-INF.

Just to hide them from the user, because in this case they're not
intended to be accessed directly by the user.

> On Mon, Mar 9, 2009 at 8:23 PM, Len Popp <le...@gmail.com> wrote:
>> What I mean is, clients *never* access a .jsp file by URL, e.g.
>> "http://www.example.com/app/foo.jsp".
>
> This is definately wrong. When you call a jsp directly from within a
> Servlet-Container, the file gets compiled to a servlet and the output
> of the servlet is displayed.

You're missing my point. I'm talking about a different way to do
things. There is another way to use JSP files, that does not require
the client to access a URL that ends in ".jsp". Look at the
documentation for RequestDispatcher. The idea is, client requests are
handled by servlets, and servlets call JSP files to produce output.
Since the JSP files are only used by the servlets, they do not have
URLs associated with them, so I "hide" them under WEB-INF.

> I've googled for this issue, and what I find, is, that some frameworks
> recommend putting JSPs into WEB-INF/jsp.
> However, I also found the statement that not all Servlet-Containers
> are supporting it.
>
> Now I'm wondering ("Mr. Servlet-Spec" Chuck, you comment on that one):
>
> Is this directory-structure really part of the specs?

Yes, it is. (Oh, I see Chuck has already answered. :-) )

> I just found this recomendation in context with frameworks like Struts
> or Spring.
>
> I'm wondering:
>
> How does Tomcat find a JSP within WEB-INF/jsp? Do I have to specify it
> in the deployment-descriptor?

No, it's invoked by your servlet code via RequestDispatcher.
-- 
Len

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: [OT] Re: Default Tomcat Page w/o Redirect

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Gregor Schneider [mailto:rc46fi@googlemail.com] 
> Subject: Re: [OT] Re: Default Tomcat Page w/o Redirect
> 
> > What I mean is, clients *never* access a .jsp file by URL, e.g.
> > "http://www.example.com/app/foo.jsp".
> 
> This is definately wrong. When you call a jsp directly from within a
> Servlet-Container, the file gets compiled to a servlet and the output
> of the servlet is displayed.

While that is true, placing a .jsp in WEB-INF prevents direct access to that JSP or the servlet it generates - which is the whole point.  Despite the admonition to not poke around in the fire unless you know what you're doing, lots of people do.

> However, I also found the statement that not all 
> Servlet-Containers are supporting it.
> 
> Now I'm wondering ("Mr. Servlet-Spec" Chuck, you comment on that one):

I'm not aware of any that don't; it would be a violation of the spec to not do so.  To quote from the spec:

"No file contained in the WEB-INF directory may be served directly to a client by the container. However, the contents of the WEB-INF directory are visible to servlet code using the getResource and getResourceAsStream method calls on the ServletContext, and may be exposed using the RequestDispatcher calls."

> Is this directory-structure really part of the specs?

WEB-INF/lib and WEB-INF/classes are, yes.  See section 9.5.

> How does Tomcat find a JSP within WEB-INF/jsp? Do I have to specify it
> in the deployment-descriptor?

No, you just reference it internally via the RequestDispatcher.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Gregor Schneider <rc...@googlemail.com>.
Dave,

On Mon, Mar 9, 2009 at 9:16 PM, David Smith <dn...@cornell.edu> wrote:
>
> Just use the jstl tag <c:import
> url="/WEB-INF/jsps/myJspFile.jsp" /> and it's done.
>

Thanks - I guess that's what I was wondering about.

Rgds

Gregor
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by David Smith <dn...@cornell.edu>.
Gregor Schneider wrote:
> Len,
>
> agreed to the most of what you said, however, I still do not see why
> JSPs have to go (or should go) into WEB-INF.
>
> Even in this tutorial (linked directly fom java.sun.com)
> http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/ the JSP-file goes
> directly into the app-dir where also the static HTML resides.
>
> On Mon, Mar 9, 2009 at 8:23 PM, Len Popp <le...@gmail.com> wrote:
>   
>> What I mean is, clients *never* access a .jsp file by URL, e.g.
>> "http://www.example.com/app/foo.jsp".
>>     
>
> This is definately wrong. When you call a jsp directly from within a
> Servlet-Container, the file gets compiled to a servlet and the output
> of the servlet is displayed.
>
> I've googled for this issue, and what I find, is, that some frameworks
> recommend putting JSPs into WEB-INF/jsp.
> However, I also found the statement that not all Servlet-Containers
> are supporting it.
>
> Now I'm wondering ("Mr. Servlet-Spec" Chuck, you comment on that one):
>
> Is this directory-structure really part of the specs?
>
> I just found this recomendation in context with frameworks like Struts
> or Spring.
>
> I'm wondering:
>
> How does Tomcat find a JSP within WEB-INF/jsp? Do I have to specify it
> in the deployment-descriptor?
>
> Rgds
>
> Gregor
>   
I've done this trick before.  It works very well if you have a lot of
jsp includes, each providing it's own templating functionality.  In that
case, you don't want the client to have direct access to those jsp files
providing only parts of the overall page.  Or maybe you want to be sure
a servlet mapping handles the request in MVC style before passing on the
request to the view via an internal forward.  Either way, it helps
protect the webapp from clients calling jsps out of the context they
were designed for.

The servlet container probably just uses something like the servlet
context's getResourceAsStream() to find the file, then compile it and
make it available.  I've never needed to do anything special in
WEB-INF/web.xml or any other config file to let tomcat know to find them
there.  Just use the jstl tag <c:import
url="/WEB-INF/jsps/myJspFile.jsp" /> and it's done.

--David

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Gregor Schneider <rc...@googlemail.com>.
Chris,

On Wed, Mar 11, 2009 at 11:13 PM, Christopher Schultz
<ch...@christopherschultz.net> wrote:
>
> No, he's telling you about /his/ webapp, not making a general statement.
>

agreed - wasn't thinking of that

>
>> Now I'm wondering ("Mr. Servlet-Spec" Chuck, you comment on that one):
>
> Aw.... you can read the spec just as well as Chuck can!
>

yep - I could read them, but Chuck knows them by heart ;)

I guess I got the concept know. What I was missing was that there's a
Controller-Servlet that's forwarding / requesting (to) the JSPs.

Rgds

Gregor
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gregor,

On 3/9/2009 3:58 PM, Gregor Schneider wrote:
> On Mon, Mar 9, 2009 at 8:23 PM, Len Popp <le...@gmail.com> wrote:
>> What I mean is, clients *never* access a .jsp file by URL, e.g.
>> "http://www.example.com/app/foo.jsp".
> 
> This is definately wrong.

No, he's telling you about /his/ webapp, not making a general statement.
He puts his JSPs beneath WEB-INF so they cannot be accessed directly. In
his application, no JSP is ever accessed directly -- it must first go
through a servlet.

> I've googled for this issue, and what I find, is, that some frameworks
> recommend putting JSPs into WEB-INF/jsp.
> However, I also found the statement that not all Servlet-Containers
> are supporting it.

I can't believe a servlet container wouldn't support this. Perhaps you
are thinking it means more than it does.

- From SRV.12.2 of the servlet spec:

"
The security model applies to the static content part of the web
application and to servlets and filters within the application that are
requested by the client. The security model does not apply when a
servlet uses the RequestDispatcher to invoke a static resource or
servlet using a forward or an include.
"

so, if you use a RequestDispatcher to forward to or include another
resource, that resource is allowed to break the normal rules for client
access. For instance, you can forward to (or include) files under WEB-INF.

> Now I'm wondering ("Mr. Servlet-Spec" Chuck, you comment on that one):

Aw.... you can read the spec just as well as Chuck can!

> Is this directory-structure really part of the specs?

It is not prohibited by the spec, so there's no reason why it should be
prohibited by a (compliant) servlet container.

> How does Tomcat find a JSP within WEB-INF/jsp? Do I have to specify it
> in the deployment-descriptor?

There's no magic, here: when you request a RequestDispatcher, you
specify the path to the resource you want to target. If you put
"/WEB-INF" at the beginning of the path, you are targeting something
beneath the WEB-INF directory.

Tomcat will never respond to a client request for a JSP (like /foo.jsp)
by looking under WEB-INF for foo.jsp and executing it. It /must/ go
through a controller servlet specifically designed to do this type of thing.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkm4N5EACgkQ9CaO5/Lv0PDvggCfVciWoMv14kZi1Q6pRdyBunvb
k8AAniU18dUTOYvvN7baNDsMYyncyt1m
=54r2
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Gregor Schneider <rc...@googlemail.com>.
Len,

agreed to the most of what you said, however, I still do not see why
JSPs have to go (or should go) into WEB-INF.

Even in this tutorial (linked directly fom java.sun.com)
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/ the JSP-file goes
directly into the app-dir where also the static HTML resides.

On Mon, Mar 9, 2009 at 8:23 PM, Len Popp <le...@gmail.com> wrote:
> What I mean is, clients *never* access a .jsp file by URL, e.g.
> "http://www.example.com/app/foo.jsp".

This is definately wrong. When you call a jsp directly from within a
Servlet-Container, the file gets compiled to a servlet and the output
of the servlet is displayed.

I've googled for this issue, and what I find, is, that some frameworks
recommend putting JSPs into WEB-INF/jsp.
However, I also found the statement that not all Servlet-Containers
are supporting it.

Now I'm wondering ("Mr. Servlet-Spec" Chuck, you comment on that one):

Is this directory-structure really part of the specs?

I just found this recomendation in context with frameworks like Struts
or Spring.

I'm wondering:

How does Tomcat find a JSP within WEB-INF/jsp? Do I have to specify it
in the deployment-descriptor?

Rgds

Gregor
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Len Popp <le...@gmail.com>.
What I mean is, clients *never* access a .jsp file by URL, e.g.
"http://www.example.com/app/foo.jsp". All URLs seen by the client are
mapped to servlets, not JSP files. All client requests are handled by
servlets, not JSP files. The servlets call various other Java objects
to do their jobs, and at the end of each servlet is a call to
RequestDispatch.forward to invoke the JSP file that formats the
servlet's output.

The reason for doing it this way is to separate app logic from page
layout. I find it difficult to code a substantial app by mixing Java
code into JSP pages, and it's lots easier to modify the format of a
web page if the app logic isn't all tangled up in it.

This is an application of the model-view-controller (MVC) method of programming.
-- 
Len



On Mon, Mar 9, 2009 at 15:04, Gregor Schneider <rc...@googlemail.com> wrote:
> Len,
>
> On Mon, Mar 9, 2009 at 7:47 PM, Len Popp <le...@gmail.com> wrote:
>>
>> Really? That's how I write all my apps! Requests are handled by
>> servlets, which forward to JSPs to format their output. Since the JSPs
>> are not intended to be served to clients directly, they must reside
>> under WEB-INF.
>>
>
> Well, that's really new to me. I'm using JSPs without using Spring,
> and the JSPs I'm writing all reside in an application's appbase (i.e.
> ${webapps}/myapp).
> They are obviously not served directly to the client since Tomcat
> compiles them beforehand so that the client always gets the
> OutputStream of said JSPs.
>
> I've just checked my books here (ok, might be a bit outdated),
> however, in none of them I found any other recommendation but to put
> the JSPs into ${webapps}/myapp except your beans which go to
> /WEB-INF/classes or /WEB-INF/lib/someJar.jar.
>
> However, I'm always eager to learn, and if that's not a
> Spring-thingie, I'd appreciated if there's any liturature available on
> the web declaring this as a best practise.
>
> Rgds
>
> Gregor
> --
> just because your paranoid, doesn't mean they're not after you...
> gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
> gpgp-key available @ http://pgpkeys.pca.dfn.de:11371
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Ken Bowen <kb...@als.com>.
I don't /know/ what best practice is here (I do more or less what you  
do), but I suspect the theory is that if a user url could arrive at a  
page, then it should be comprehensible to the user.  I don't think I  
support that.  If users go poking around were they don't belong, they  
get what they deserve (all too long ago, my daddy taught me not to  
poke in the fire unless I knew what I was doing).

--Ken

On Mar 9, 2009, at 3:04 PM, Gregor Schneider wrote:

> Len,
>
> On Mon, Mar 9, 2009 at 7:47 PM, Len Popp <le...@gmail.com> wrote:
>>
>> Really? That's how I write all my apps! Requests are handled by
>> servlets, which forward to JSPs to format their output. Since the  
>> JSPs
>> are not intended to be served to clients directly, they must reside
>> under WEB-INF.
>>
>
> Well, that's really new to me. I'm using JSPs without using Spring,
> and the JSPs I'm writing all reside in an application's appbase (i.e.
> ${webapps}/myapp).
> They are obviously not served directly to the client since Tomcat
> compiles them beforehand so that the client always gets the
> OutputStream of said JSPs.
>
> I've just checked my books here (ok, might be a bit outdated),
> however, in none of them I found any other recommendation but to put
> the JSPs into ${webapps}/myapp except your beans which go to
> /WEB-INF/classes or /WEB-INF/lib/someJar.jar.
>
> However, I'm always eager to learn, and if that's not a
> Spring-thingie, I'd appreciated if there's any liturature available on
> the web declaring this as a best practise.
>
> Rgds
>
> Gregor
> -- 
> just because your paranoid, doesn't mean they're not after you...
> gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
> gpgp-key available @ http://pgpkeys.pca.dfn.de:11371
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Re: Default Tomcat Page w/o Redirect

Posted by Gregor Schneider <rc...@googlemail.com>.
Len,

On Mon, Mar 9, 2009 at 7:47 PM, Len Popp <le...@gmail.com> wrote:
>
> Really? That's how I write all my apps! Requests are handled by
> servlets, which forward to JSPs to format their output. Since the JSPs
> are not intended to be served to clients directly, they must reside
> under WEB-INF.
>

Well, that's really new to me. I'm using JSPs without using Spring,
and the JSPs I'm writing all reside in an application's appbase (i.e.
${webapps}/myapp).
They are obviously not served directly to the client since Tomcat
compiles them beforehand so that the client always gets the
OutputStream of said JSPs.

I've just checked my books here (ok, might be a bit outdated),
however, in none of them I found any other recommendation but to put
the JSPs into ${webapps}/myapp except your beans which go to
/WEB-INF/classes or /WEB-INF/lib/someJar.jar.

However, I'm always eager to learn, and if that's not a
Spring-thingie, I'd appreciated if there's any liturature available on
the web declaring this as a best practise.

Rgds

Gregor
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


[OT] Re: Default Tomcat Page w/o Redirect

Posted by Len Popp <le...@gmail.com>.
On Mon, Mar 9, 2009 at 05:13, Gregor Schneider <rc...@googlemail.com> wrote:
> JSPs in WEB-INF-folder?
>
> Well, I'm not familiar with Spring, however, *that* concept is
> completely new to me...

Really? That's how I write all my apps! Requests are handled by
servlets, which forward to JSPs to format their output. Since the JSPs
are not intended to be served to clients directly, they must reside
under WEB-INF.

Spring is an application framework that does basically the same thing,
and a typical Spring app has JSPs stored in WEB-INF.
-- 
Len

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Default Tomcat Page w/o Redirect

Posted by Gregor Schneider <rc...@googlemail.com>.
On Mon, Mar 9, 2009 at 3:00 AM, mitalub <mi...@yahoo.com> wrote:
>
> The corresponding ***jsp*** and java classes all sit within WEB-INF.  Setting the
> welcome page seems to work for static welcome pages only... is this true, or
> am I doing something wrong?
>
JSPs in WEB-INF-folder?

Well, I'm not familiar with Spring, however, *that* concept is
completely new to me...

Rgds

Gregor
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Default Tomcat Page w/o Redirect

Posted by mitalub <mi...@yahoo.com>.
Thanks for the reply.  Tomcat version is 6.0.14.  

The trouble is that the home page is not static.  I'd access the page
through www.mydomain.com/app/home, but there is a mapping in my
spring-servlet.xml (i'm using spring) which maps this to the controller. 
The corresponding jsp and java classes all sit within WEB-INF.  Setting the
welcome page seems to work for static welcome pages only... is this true, or
am I doing something wrong?



Caldarale, Charles R wrote:
> 
>> From: mitalub [mailto:mitalub@yahoo.com] 
>> Subject: Default Tomcat Page w/o Redirect
>> 
>> Currently, my home page is at 
>> http://www.mydomain.com/myappname/app/home.
>> 
>> I want to be able to access this page by going to just
>> http://www.mydomain.com, but without a redirect.
> 
> You didn't bother to tell us the version of Tomcat you're using, but if
> it's a reasonably recent one, you need to name your webapp ROOT (case
> sensitive), not myappname, for it to be the default webapp.
> 
> Home pages are normally in the base directory of the webapp, but if you
> insist on keeping your home page in an unusual location, set it in the
> <welcome-file> list in your webapp's WEB-INF/web.xml file; e.g.:
> 
>     <welcome-file-list>
>         <welcome-file>app/home/index.html</welcome-file>
>     </welcome-file-list>
> 
> using whatever the actual name of your home page is.
> 
>  - Chuck
> 
> 
-- 
View this message in context: http://www.nabble.com/Default-Tomcat-Page-w-o-Redirect-tp22405664p22405937.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Default Tomcat Page w/o Redirect

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: mitalub [mailto:mitalub@yahoo.com] 
> Subject: Default Tomcat Page w/o Redirect
> 
> Currently, my home page is at 
> http://www.mydomain.com/myappname/app/home.
> 
> I want to be able to access this page by going to just
> http://www.mydomain.com, but without a redirect.

You didn't bother to tell us the version of Tomcat you're using, but if it's a reasonably recent one, you need to name your webapp ROOT (case sensitive), not myappname, for it to be the default webapp.

Home pages are normally in the base directory of the webapp, but if you insist on keeping your home page in an unusual location, set it in the <welcome-file> list in your webapp's WEB-INF/web.xml file; e.g.:

    <welcome-file-list>
        <welcome-file>app/home/index.html</welcome-file>
    </welcome-file-list>

using whatever the actual name of your home page is.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Default Tomcat Page w/o Redirect

Posted by mitalub <mi...@yahoo.com>.
Thanks a lot, I hadn't thought of the difference between redirect and
forward, but this did the trick!


In practice, I've found the easiest way is to do this:
- Create index.jsp
- Add a one line /index.jsp which does a forward to your home page like 
this:

<jsp:forward page='/whatever-/path-that-was/index.do'/>

-Tim


-- 
View this message in context: http://www.nabble.com/Default-Tomcat-Page-w-o-Redirect-tp22405664p22426951.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Default Tomcat Page w/o Redirect

Posted by Tim Funk <fu...@joedog.org>.
In practice, I've found the easiest way is to do this:
- Create index.jsp
- Add a one line /index.jsp which does a forward to your home page like 
this:

<jsp:forward page='/whatever-/path-that-was/index.do'/>

-Tim


mitalub wrote:
> Hi,
> 
> I've tried searching around for this, but I can't find a clear answer, so am
> starting to think it's not possible.
> 
> Currently, my home page is at http://www.mydomain.com/myappname/app/home.
> 
> I want to be able to access this page by going to just
> http://www.mydomain.com, but without a redirect.  In other words, the
> address in the address bar should remain short & sweet.  Is this possible
> with tomcat?  
> 
> Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org