wood burning stoves 2.0*
The moose likes JSP and the fly likes Getting started with JSP-Servlet using apache-tomcat-5.5.17 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Getting started with JSP-Servlet using apache-tomcat-5.5.17" Watch "Getting started with JSP-Servlet using apache-tomcat-5.5.17" New topic
Author

Getting started with JSP-Servlet using apache-tomcat-5.5.17

Riyaz Saiyed
Greenhorn

Joined: Aug 13, 2006
Posts: 22
Hi all,
I'm trying to run an example which display fist - a login page. Then there is a call to servlet which retrieves user name and finally displays welcome message to the user.

My directory structure..
1) Root directory : TOMCATE_INST_DIR\webapps\onJava
2) login.jsp : TOMCATE_INST_DIR\webapps\onJava\login.jsp
3) welcome.jsp : TOMCATE_INST_DIR\webapps\onJava\welcome.jsp
4) web.xml : TOMCATE_INST_DIR\webapps\onJava\WEB-INF\web.xml
5) servlet class : TOMCATE_INST_DIR\webapps\onJava\WEB-INF\clssses\com
\onjava\login.class

My login.jsp include code to call servlet:
<form name="loginForm" method="post" action="servlet/com.onjava.login">
My login.java include cole to redirect requst to welcome.jsp

I've made followin entry in TOMCATE_INST_DIR\conf\server.xml
<Context path="/onJava" docBase="onJava" debug="0" reloadable="true" />

Now when i invoke my login page : http://localhost:8080/onJava/login.jsp
i get login screen where i supposed to provide user name. once i do this,
i invoke login servlet (com.onjava.login.class), which should display welcome message (welcome.jsp)

But while invoking servlet i get following error
HTTP Status 404 - /onJava/servlet/com.onjava.login

type Status report

message /onJava/servlet/com.onjava.login



What's wrong with the configuration (Above structure works fine if i put all my code under ROOT dir).

I've followed example :
http://www.onjava.com/pub/a/onjava/2001/04/19/tomcat.html?page=1

Please guide me..
[ October 10, 2006: Message edited by: Riyaz Saiyed ]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I think that you need to enable the ugly servlet invoker.
Open tomcat's /conf/web.xml. Look for "invoker" in this file, and uncomment the invoker servlet. Reboot Tomcat, and retry.


[My Blog]
All roads lead to JavaRanch
Riyaz Saiyed
Greenhorn

Joined: Aug 13, 2006
Posts: 22
Ya.. Its already uncommented...
I did it when I tried my first example..
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Uncommenting the invoker servlet is a bad way to start out, in my opinion.
Can you post the contents of your web.xml file?

Also, if you want an example of a proper webapp, you can download any of the war files from my site http://simple.souther.us and drop them in your webapps directory.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Riyaz Saiyed
Greenhorn

Joined: Aug 13, 2006
Posts: 22
Content of web.xml : TOMCATE_INST_DIR\webapps\onJava\WEB-INF\web.xml


<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<!-- The onJava ExampleServlet -->
<servlet>
<servlet-name>login</servlet-name>
<servlet-class>com.onjava.login</servlet-class>
</servlet>
</web-app>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting started with JSP-Servlet using apache-tomcat-5.5.17