Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Servlet problem: Page does not load

  Asked By: Juana    Date: Jun 30    Category: Java    Views: 884
  

I am learning servlet programming and I have not gotten to display a page
properly. It is quite frustrating because I get a message that the
page does not exist.

I start tomcat, load IE, and try the URL

http://localhost:8080/myApp/servlet/Primitive

Primitive is the name of the servlet I want to run.

I am using IE 5.5, WIN2000 sp4, jsdk1.4, tomcat 4.1

I followed all the instructions to install and set tomcat.

Under c:\tomcat\webapps I created a directory named myApps and
inside it I created a dir name WEB-INF. In this directory I have created
a dir named classes and a file named web.xml.

My classpath and path are set for:

JAVA_HOME = c:\j2sdk1.4.1_02
path = %PATH%;%JAVA_HOME%\\bin
CLASSPATH =
.;%JAVA_HOME%\bin;c:\jakarta-tomcat-4.1.30\common\lib\servlet.jar


The codes are (actually they were taking from a book)

import javax.servlet.*;
import java.io.IOException;

public class PrimitiveServlet implements Servlet {

public void init(ServletConfig config) throws ServletException {
System.out.println("init");
}

public void service(ServletRequest request, ServletResponse response)
throws ServletException, IOException {
System.out.println("service");
}

public void destroy() {
System.out.println("destroy");
}

public String getServletInfo() {
return null;
}
public ServletConfig getServletConfig() {
return null;
}

}


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

<!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>
<servlet>
<servlet-name>Primitive</servlet-name>
<servlet-class>PrimitiveServlet</servlet-class>
</servlet>
</web-app>

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Benjamin Simpson     Answered On: Jun 30

with most appservers, you either need to go through their application
deployment procedure or else deploy manually (by creating the files on
your own) and change some configuration files.

basically, you would be best off by putting your application into a war
file and deploying through the admin interfaace of your appserver. for
tomcat, if you go to localhost:8080, you should see links on the left
side for admin/manager pages.

 
Answer #2    Answered By: Adalwen Fischer     Answered On: Jun 30

http://localhost:8080/myApp/servlet/Primitive

Primitive is the name of the servlet  I want to run.

I am using IE 5.5, WIN2000 sp4, jsdk1.4, tomcat  4.1

I followed all the instructions to install  and set  tomcat.

Under c:\tomcat\webapps I created  a directory  named myApps and
inside it I created a dir name WEB-INF. In this directory I have created
a dir named  classes and a file  named web.xml.

check with the name mismatch first..

 
Answer #3    Answered By: Dylan Evans     Answered On: Jun 30

Well, I was dumb and didn't see it until yesterday..

What I made was exactly pretty dumb. I am using a book that used
Tomcat 4.0 and I had tomcat  4.1. 4.1 requires a few settings whereas
4.0 works well for the example...

 
Didn't find what you were looking for? Find more on Servlet problem: Page does not load Or get search suggestion and latest updates.




Tagged: