1

I'm trying to configure a tomcat server to start developing servlet/jsp but I get server not found. Here is what I did so far:

Added CLASSPATH to .bash_profile and my servlet compiled successfully.

I typed which java which outputted /usr/bin/java

I then added export JAVA_HOME=/usr/bin/java to .bash_profile

Removed the comments around servlet-mapping as well as the Invoker.

Changed the permission of /usr/share/tomcat6/webapps to world access.

Logged out as root and then logged into my regular account to create WEB-INF/classes under /usr/share/tomcat6/webapps

I then moved the .class from the servlet I compiled to /usr/share/tomcat6/webappsWEB-INF/classes

started a terminal, su to service tomcat6 start then switched user to my normal account and type service tomcat6 status, the output was tomcat 6 running.

Finally, I started my web browser type localhost:8080/servlet/first
and I got server not found. Tried localhost:8080, server not found; however, if I type 127.0.0.1:8080/servlet/first or 127.0.0.1:8080, I get a white page with no error message.

The servlet first will only output Hello World.

I couldn't find the Context path="" docBase="" reloadable="true" line in server.xml

I also search in context.xml, web.xml, and tomcat-users.xml and couldn't find it.

Any suggestions please?

I created a web.xml file inside /usr/share/tomcat6/webapps/WEB-INF, which contains the following lines:

<?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>first</servlet-name>
<servlet-class>first</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>first</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>

Still I get server not found. Any thing else I should try?

4

1 回答 1

1

从您所说的来看,听起来您正试图从服务器的 ROOT webapp 运行 servlet。

如果是这样,那么问题将是:您是否有 /etc/tomcat6/Catalina/localhost/ROOT.xml 文件?

或者,更重要的是,就 *.xml 文件而言,在 /etc/tomcat6/Catalina/localhost/ 下有什么?这是各个 webapp 配置文件的位置,只要将 Context 条目与 docBase 配置一起放入。

希望有帮助。让我们知道。

于 2013-11-07T22:51:29.970 回答