aspose file tools*
The moose likes Servlets and the fly likes The requested resource (/servlet/LoginServlet) is not available Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "The requested resource (/servlet/LoginServlet) is not available" Watch "The requested resource (/servlet/LoginServlet) is not available" New topic
Author

The requested resource (/servlet/LoginServlet) is not available

Orem Hun
Greenhorn

Joined: May 24, 2005
Posts: 28
Need help with the above error.
I've a mbWelcome.jsp which has the following POST action:
<form name="mbWelcome" method="POST" action="/servlet/LoginServlet">

And the web.xml lines for this servlet are:

<servlet>
<servlet-name>LoginServlet</servlet-name>
<display-name>LoginServlet</display-name>
<servlet-class>minibank.web.LoginServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/servlet/LoginServlet</url-pattern>
</servlet-mapping>

I've LoginServlet.class file in Tomcat installation webapps/MiniBank/WEB-INF/classes/minibank/web/LoginServlet.class

When I submit from mbWelcome.jsp, the LoginServlet action not being invoked, Tomcat is not able to see the class LoginServlet, and giving error in the subject. I think some thing is missing in my configuration, can any one explain this behaviour.

thanks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You don't need the 'servlet' keyword in your url.
Try:
<form name="mbWelcome" method="POST" action="LoginServlet">


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

"java_r",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Orem Hun
Greenhorn

Joined: May 24, 2005
Posts: 28
I've tried with the following: <form name="mbWelcome" method="POST" action="LoginServlet">

It did not work. The URL it looks for the servlet now is: http://localhost/MiniBank/Jsp/LoginServlet

Basically, this corresponds to same directory where the mbWelcome.jsp exists. I've brought up mbWelcome.jsp using http://localhost/MiniBank/Jsp/mbWelcome.jsp

For some reason, it looks for the Servlet class in the local dir. I thought adding the following lines to web.xml would make it look at: webapps/MiniBank/WEB-INF/classes/minibank/web/LoginServlet.class

web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">


<web-app id="WebApp">
<display-name>MyBankWeb</display-name>

<servlet>
<servlet-name>LoginServlet</servlet-name>
<display-name>LoginServlet</display-name>
<servlet-class>minibank.web.LoginServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/servlet/LoginServlet</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>mbWelcome.jsp</welcome-file>
</welcome-file-list>
</web-app>
-------

I think, some how the URL is not able to be mapped to the correct location of the class.

thanks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

It needs to match the url-pattern (but without the beginning slash.
Sorry, I did not notice that you had /servlet in your mapping.

<url-pattern>/servlet/LoginServlet</url-pattern>

Try:
<form name="mbWelcome" method="POST" action="servlet/LoginServlet">

The slash at the beginning will cause your browser to omit the contextPath.
This is probably what the issue was.
Orem Hun
Greenhorn

Joined: May 24, 2005
Posts: 28
I did not realize the issue with the starting slash, I've corrected that. However, that did not change any of the behaviour ( I did restart Tomcat).

Now jsp has: <form name="mbWelcome" method="POST" action="servlet/LoginServlet">

web.xml has:
<servlet>
<servlet-name>LoginServlet</servlet-name>
<display-name>LoginServlet</display-name>
<servlet-class>minibank.web.LoginServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/servlet/LoginServlet</url-pattern>
</servlet-mapping>

This is first time writing JSP/servlet app for Tomcat, I don't have a working example to compare, so it is mysterious for me to how to make Tomcat run my servlet class.

Appreciate all your time.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you want some examples, look at http://simple.souther.us.
It's a collection of demo apps, packaged as war files that can be deployed in a running instance of Tomcat with a couple mouseclicks.
Orem Hun
Greenhorn

Joined: May 24, 2005
Posts: 28
Sure, thanks, I am looking at some of them.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: The requested resource (/servlet/LoginServlet) is not available