servlet mapping problems  
Author Message
jodasi





PostPosted: 2003-11-4 7:07:00 Top

java-programmer, servlet mapping problems Hey guys/gals. My first attempted at servlet mapping flubbed.

Background:
A friend at work suggested I store my source in webapps\wbrl\jsp
So I have Tomcat\webapps\wbrl\jsp\WebRoll.jsp

Currently I type http://localhost:8080/wbrl/jsp/WebRoll3.jsp

This brings up my application successfully.

I would like to be able to type http://localhost:8080/wbrl and have
it bring up my web page.

So I tried to change the web.xml, but it doesnt work.

<servlet>
<servlet-name>WebRoll3</servlet-name>
<servlet-class>WebRoll3</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>WebRoll3</servlet-name>
<url-pattern>/wbrl/*</url-pattern>
</servlet-mapping>

<url-pattern>/wbrl/*</url-pattern> causes "Wrapper cannot find servlet
class WebRoll3 or a class it"

How do i fix this? Do I use filter mapping? I got totally lost in the
filter mapping explanation.
 
Wendy S





PostPosted: 2003-11-4 11:44:00 Top

java-programmer >> servlet mapping problems joel s wrote:

> Hey guys/gals. My first attempted at servlet mapping flubbed.

You don't have a servlet, there's nothing to map. (Well, technically JSP's
do get converted to Servlet code, but you don't use <servlet> and
<servlet-mapping> for JSP's.)

> Currently I type http://localhost:8080/wbrl/jsp/WebRoll3.jsp
> This brings up my application successfully.
> I would like to be able to type http://localhost:8080/wbrl and have
> it bring up my web page.

Put it in the 'Welcome Files' list and Tomcat will redirect to that .jsp
when it receives a request with no filename specified. You posted that bit
of web.xml in your other message, but it still lists index.html/index.jsp
instead of the file you want Tomcat to serve up.

> How do i fix this? Do I use filter mapping? I got totally lost in the
> filter mapping explanation.

You'd first have to write a class that extends Filter. I don't think that's
what you want for this problem.

--
Wendy in Chandler, AZ
 
jodasi





PostPosted: 2003-11-5 1:20:00 Top

java-programmer >> servlet mapping problems Ok, well, I added <welcome-file>WebRoll3.jsp</welcome-file>
<servlet>
<servlet-name>WebRoll3</servlet-name>
<servlet-class>WebRoll3</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>WebRoll3</servlet-name>
<url-pattern>/wbrl/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>WebRoll3.jsp</welcome-file>
</welcome-file-list>

It brings me to:

http://localhost:8080/wbrl/
Directory Listing For /
-----------------------------------------------------
Filename Size Last Modified
jsp/

Then I have click "jsp/" to get to the welcome page

How do I get it to do what I want which is type:
"http://localhost:8080/wbrl"

and have it bring me to:

http://localhost:8080/wbrl/jsp/WebRoll3.jsp

Regards, Joel S

Wendy S <email***@***.com> wrote in message news:<ZfFpb.3249$7B2.2948@fed1read04>...
> joel s wrote:
>
> > Hey guys/gals. My first attempted at servlet mapping flubbed.
>
> You don't have a servlet, there's nothing to map. (Well, technically JSP's
> do get converted to Servlet code, but you don't use <servlet> and
> <servlet-mapping> for JSP's.)
>
> > Currently I type http://localhost:8080/wbrl/jsp/WebRoll3.jsp
> > This brings up my application successfully.
> > I would like to be able to type http://localhost:8080/wbrl and have
> > it bring up my web page.
>
> Put it in the 'Welcome Files' list and Tomcat will redirect to that .jsp
> when it receives a request with no filename specified. You posted that bit
> of web.xml in your other message, but it still lists index.html/index.jsp
> instead of the file you want Tomcat to serve up.
>
> > How do i fix this? Do I use filter mapping? I got totally lost in the
> > filter mapping explanation.
>
> You'd first have to write a class that extends Filter. I don't think that's
> what you want for this problem.
 
 
Ben_





PostPosted: 2003-11-5 1:28:00 Top

java-programmer >> servlet mapping problems You get a directory listing because there is not default document in /wbrl.

Place a WebRoll3.jsp in /wbrl to redirect to the place you like (with
response.sendRedirect for example). Of course you may want to add a
'welcome-file' entry with 'index.jsp' (which a bit more standard :-).


 
 
Sudsy





PostPosted: 2003-11-5 1:30:00 Top

java-programmer >> servlet mapping problems joel s wrote:
> Ok, well, I added <welcome-file>WebRoll3.jsp</welcome-file>
> <servlet>
> <servlet-name>WebRoll3</servlet-name>
> <servlet-class>WebRoll3</servlet-class>
> </servlet>
> <servlet-mapping>
> <servlet-name>WebRoll3</servlet-name>
> <url-pattern>/wbrl/*</url-pattern>
> </servlet-mapping>
> <welcome-file-list>
> <welcome-file>WebRoll3.jsp</welcome-file>

<welcome-file>/jsp/WebRoll3.jsp</welcome-file>

> </welcome-file-list>
>

 
 
Wendy S





PostPosted: 2003-11-5 8:05:00 Top

java-programmer >> servlet mapping problems joel s wrote:
> Ok, well, I added <welcome-file>WebRoll3.jsp</welcome-file>
> It brings me to:
> Directory Listing For /
> Then I have click "jsp/" to get to the welcome page
> How do I get it to do what I want which is type:
> "http://localhost:8080/wbrl"
> and have it bring me to:
> http://localhost:8080/wbrl/jsp/WebRoll3.jsp

Without any path given, it expected to find your file in the root of the
webapp directory. It didn't, so it gave up and showed you the contents of
the directory. You need this instead:

<welcome-file>jsp/WebRoll3.jsp</welcome-file>

(Sudsy, you have a leading slash, but SRV.9.10 says "The welcome file list
is an ordered list of partial URLs with no trailing or leading /.")

Joel, you might want to download the Servlet Specification and at least flip
through it so you know what's there. The behavior you're trying to get is
covered chapter 9 of the Java Servlet Specification Version 2.3. This
document explains what your Servlet container is required to do for you,
which is useful when you're wondering, "Why won't it ___?" and "How do I
___?"

--
Wendy in Chandler, AZ