• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Riyaz Saiyed
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya.. Its already uncommented...
I did it when I tried my first example..
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Riyaz Saiyed
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
reply
    Bookmark Topic Watch Topic
  • New Topic