File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes .jsp mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark ".jsp mapping" Watch ".jsp mapping" New topic
Author

.jsp mapping

Hugh O'Donnell
Greenhorn

Joined: Jul 30, 2004
Posts: 13
Hi all,

I've just started using Resin and it's fantastic, but I'm having a bit of trouble with something that should be very simple. I have the following in a file in resin-3.0.9\webapps\jsptest\hello.jsp :

Hello World!

In resin-3.0.9\webapps\jsptest\WEB-INF\web.xml I have the following :

<web-app>
<servlet servlet-name="jsppage"
servlet-class="hello">
</servlet>

<servlet-mapping url-pattern="/hello"
servlet-name="jsppage"/>
</web-app>

However, the problem is, when I type the URL http://localhost:8080/jsptest/hello I get the following

error from Resin :

500 Servlet Exception
WEB-INF/web.xml:4: `hello' is not a known servlet. Servlets belong
in the classpath, often in WEB-INF/classes.

--------------------------------------------------------------------
Resin-3.0.s041002 (built Sat, 02 Oct 2004 04:47:31 PDT)

I just don't get it. When I delete my web.xml file and try the URL http://localhost:8080/jsptest/hello.jsp it works fine. I have tried to manually compile the .jsp file but to no avail. I just want to be able to have a mapping between a URL and a .jsp file. Can anyone see what I'm doing wrong? When hello.jsp is compiled by Resin, I am assuming it is compiled to hello.class, as specified in my servlet-class="hello". I think this might be the problem.

Any help would be greatly appreciated.
[ October 11, 2004: Message edited by: Bear Bibeault ]

Hugh O'Donnell<br /> <br />SCJP 1.4, SCJD, SCBCD 1.3, SCWCD 1.4
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Hugh,

Try something along these lines. First you specify the servlet-name to JSP page mappping, in this case from 'test' to test.jsp.

Then you map the url pattern to the servlet defined in the first mapping, which effectively maps the url pattern to the JSP page.



HTH

Sonny
[ October 11, 2004: Message edited by: Sonny Gill ]

The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
Hugh O'Donnell
Greenhorn

Joined: Jul 30, 2004
Posts: 13
That did the trick exactly, thanks a million Sonny. I didn't realise I had to specify jsp-file instead of servlet-class.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61191
    
  66

Since this turned out not to be Resin-specific, I have modified the topic title accordingly.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: .jsp mapping