Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > servlet mapping problems

Reply
Thread Tools

servlet mapping problems

 
 
joel s
Guest
Posts: n/a
 
      11-03-2003
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.
 
Reply With Quote
 
 
 
 
Wendy S
Guest
Posts: n/a
 
      11-04-2003
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
 
Reply With Quote
 
 
 
 
joel s
Guest
Posts: n/a
 
      11-04-2003
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 <> 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.

 
Reply With Quote
 
Ben_
Guest
Posts: n/a
 
      11-04-2003
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 .


 
Reply With Quote
 
Sudsy
Guest
Posts: n/a
 
      11-04-2003
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>
>


 
Reply With Quote
 
Wendy S
Guest
Posts: n/a
 
      11-05-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM
servlet mapping problems <continued> joel s Java 0 11-03-2003 11:10 PM
Servlet Mapping - What's the point? Fran Cotton Java 3 08-08-2003 08:28 AM
Servlet URL Mapping Evil! Fran Cotton Java 0 07-25-2003 03:41 PM
problems with servlet-mapping url-pattern lbrtchx Albretch Java 2 07-11-2003 08:19 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57