You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by andy davidson <ba...@yahoo.com> on 2004/10/17 18:23:09 UTC
trouble with static html using 5.5.2
Hi
I just installed the binary release of 5.5.2. do I
have to change something in a config file to so that
tomcat can server up html?
Here is my test. I created servlet foo.bar.bazServlet.
I installed it under webapps/baz. I created <servlet>
tags in webapps/baz/WEB-INF/web.xml
http://localhost:8080/baz works as expected.
I have a file webapps/bas/test.html
http://localhost:8080/baz/test.html causes my servlet
to run? Do I have to create some sort of mapping entry
in webapps/bas/WEB-INF/web.xml for html to work?
my servlet generates a image tag as follows
<img src=images/baz.gif>
i have webapps/bas/images/baz.gif installed how ever
this image is never loaded into my browser? Do I have
to create some sort of mapping entry in
webapps/bas/WEB-INF/web.xml for html to work?
thanks in advance
andy
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: trouble with static html using 5.5.2
Posted by David Smith <dn...@cornell.edu>.
I second the advice on reading the spec. Here's a link to it (version 2.4):
http://jcp.org/aboutJava/communityprocess/final/jsr154/index.html
--David
QM wrote:
>On Sun, Oct 17, 2004 at 12:22:39PM -0700, andy davidson wrote:
>: http://localhost:8080/baz works as expected
>
>Probably not. Read on:
>
>
>: <servlet-mapping>
>: <servlet-name>baz</servlet-name>
>: <url-pattern>/</url-pattern>
>: </servlet-mapping>
>
>That's probably not the pattern you meant; it will fire the "baz"
>servlet for *any* request to your webapp that isn't otherwise mapped.
>It's known as the "default servlet."
>
>Try it: request
> http://{your server}/baz/something
> http://{your server}/baz/something/else
>
>... ad infinitum (and ad nauseam)...
>
>
>: My guess is I need some sort of url-pattern that maps
>: /baz/* to /baz/*. What would the syntax be? this is
>: not a servlet thing? where can I find a dtd for
>: web.xml?
>
>There's no need to guess: all of this and more is explained in the
>servlet spec (and any worthwhile servlet text), as I mentioned in my
>previous message. ;) For example, your mapping question is explained in
>"SRV.11.2 Specification of Mappings."
>
>Here's a hint: your web.xml should at least include a prologue, which
>specifies the servlet spec 2.3 DTD (for Tomcat 4.x and earlier) or the
>2.4 schema (for Tomcat 5.x and later).
>
>
>-QM
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: trouble with static html using 5.5.2
Posted by QM <qm...@brandxdev.net>.
On Sun, Oct 17, 2004 at 12:22:39PM -0700, andy davidson wrote:
: http://localhost:8080/baz works as expected
Probably not. Read on:
: <servlet-mapping>
: <servlet-name>baz</servlet-name>
: <url-pattern>/</url-pattern>
: </servlet-mapping>
That's probably not the pattern you meant; it will fire the "baz"
servlet for *any* request to your webapp that isn't otherwise mapped.
It's known as the "default servlet."
Try it: request
http://{your server}/baz/something
http://{your server}/baz/something/else
... ad infinitum (and ad nauseam)...
: My guess is I need some sort of url-pattern that maps
: /baz/* to /baz/*. What would the syntax be? this is
: not a servlet thing? where can I find a dtd for
: web.xml?
There's no need to guess: all of this and more is explained in the
servlet spec (and any worthwhile servlet text), as I mentioned in my
previous message. ;) For example, your mapping question is explained in
"SRV.11.2 Specification of Mappings."
Here's a hint: your web.xml should at least include a prologue, which
specifies the servlet spec 2.3 DTD (for Tomcat 4.x and earlier) or the
2.4 schema (for Tomcat 5.x and later).
-QM
--
software -- http://www.brandxdev.net
tech news -- http://www.RoarNetworX.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: trouble with static html using 5.5.2
Posted by andy davidson <ba...@yahoo.com>.
please see my comments bellow
thanks
andy
--- QM <qm...@brandxdev.net> wrote:
> On Sun, Oct 17, 2004 at 09:23:09AM -0700, andy
> davidson wrote:
>
> : Here is my test. I created servlet
> foo.bar.bazServlet.
> : I installed it under webapps/baz. I created
> <servlet>
> : tags in webapps/baz/WEB-INF/web.xml
>
http://localhost:8080/baz works as expected
> What about <servlet-mapping> tags? Those are
> required to map the
> servlet class to a (context-relative) URI.
>
>
> : http://localhost:8080/baz/test.html causes my
> servlet
> : to run? Do I have to create some sort of mapping
> entry
> : in webapps/bas/WEB-INF/web.xml for html to work?
>
here is my web.xml file. What am I missing?
<web-app>
<servlet>
<servlet-name>baz</servlet-name>
<servlet-class>foo.bar.bazServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>baz</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
My guess is I need some sort of url-pattern that maps
/baz/* to /baz/*. What would the syntax be? this is
not a servlet thing? where can I find a dtd for
web.xml?
thanks andy
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: trouble with static html using 5.5.2
Posted by QM <qm...@brandxdev.net>.
On Sun, Oct 17, 2004 at 09:23:09AM -0700, andy davidson wrote:
: I just installed the binary release of 5.5.2. do I
: have to change something in a config file to so that
: tomcat can server up html?
Not at all, as long as the context (webapp) has properly deployed.
: Here is my test. I created servlet foo.bar.bazServlet.
: I installed it under webapps/baz. I created <servlet>
: tags in webapps/baz/WEB-INF/web.xml
What about <servlet-mapping> tags? Those are required to map the
servlet class to a (context-relative) URI.
: http://localhost:8080/baz/test.html causes my servlet
: to run? Do I have to create some sort of mapping entry
: in webapps/bas/WEB-INF/web.xml for html to work?
See above.
: my servlet generates a image tag as follows
: <img src=images/baz.gif>
: i have webapps/bas/images/baz.gif installed how ever
: this image is never loaded into my browser? Do I have
: to create some sort of mapping entry in
: webapps/bas/WEB-INF/web.xml for html to work?
Avoid using relative paths from a servlet. The spec doesn't mandate how
a servlet's relative path is handled, since a servlet is a virtual
entity.
A thorough review of the servlet spec (available at java.sun.com) will
provide more insight, as should several introductory J2EE/servlet texts.
If you use JSPs instead of servlets for your presentation content, you
can use a special JSTL tag to reference context-relative links, images,
and other static content.
-QM
--
software -- http://www.brandxdev.net
tech news -- http://www.RoarNetworX.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org