• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

new errors!

 
kumar nagur
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai everybody, I have java in "c" & tomcat also in "c" I wrote a servlet and compiled it .Now I got the class file. Now I moved the class fileto: C:\Tomcat 5.0\webapps\servlets-examples\WEB-INF\classes Afterwards I don't know what to do to run a servlet? (somebody told me to include servlet in C:\Tomcat 5.0\webapps\servlets-examples\WEB-INF\web.xml, like <servlet-mapping> <servlet-name>HelloWorld</servlet-name> <url-pattern>/servlet/HeeloWorld</url-pattern> </servlet-mapping> when I tried to do I am getting errors in Tomcat server.) so please help me out. I am in confusion. I appreciate u r help. Thank you.
 
Sri Basavanahally
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumar,
What does your servlet do ? Does it generate an HTML response ? If so, you need to type in something like:
http://localhost ortnumber/context/servlet/servletname to run it.
You need to have a web.xml file under your WEB-INF directory. This should include servlet-name, context name etc. look for a samples like this:
<?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>
<display-name>Webdav Content Management</display-name>
<description>
Webdav Content Management
</description>
<servlet>
<servlet-name>webdav</servlet-name>
<servlet-class>org.apache.catalina.servlets.WebdavServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<!-- Uncomment this to enable read and write access -->
<!--
<init-param>
<param-name>readonly</param-name>
<param-value>false</param-value>
</init-param>
-->
<!--load-on-startup>1</load-on-startup-->
</servlet>
<!-- The mapping for the webdav servlet -->
<servlet-mapping>
<servlet-name>webdav</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
....
....
</web-app>
 
kumar nagur
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you sri for u r response.
u r right I want get a HTML response.
but when ever I include
<servlet-mapping>
<servlet-name>New</servlet-name>
<url-pattern>/servlet/New</url-pattern>
</servlet-mapping>
in my C:\Tomcat 5.0\webapps\servlets-examples\WEB-INF\web.xml document and save it.Then once again when I try to start the Tomcat I am getting errors .
And I couldn't be able to run the servlet too

I am doing like this in the browser
http://localhost:8080/servlet-exmples\servlet\New
and I am getting a error page.
 
kumar nagur
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry ,like this
http://localhost:8080/servlet-exmples/servlet/New
 
kumar nagur
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help me out!!
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see where you tell us what error you actually get.
You seem to be mixing URL styles here - using a url with "/servlet/" is going to direct the requests to the "invoker" servlet if it happens to be turned on in the particular web application.
It looks like you didn't put your servlet class in a package - that can cause lots of trouble.
Tomcat 5 is still in beta, isn't it?
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic