| | |
running servlets
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2007
Posts: 5
Reputation:
Solved Threads: 0
hi...
how to compile and run a servlet application using Tomcat5.5 ...
where to place the class path......and how to run....
After compiling Java file I have placed .class file in ...
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes
and my java file is in...
C:\servlets/HelloWorld.java
and i have accessed like this....
http://localhost:8080/servlet/HelloWorld
i m getting error like this.......
HTTP Status 404 - /servlet/HelloWorld
type Status report
message /servlet/HelloWorld
description The requested resource (/servlet/HelloWorld) is not available.
Apache Tomcat/5.0.25
Can anyone suggest a solution to this.........
how to compile and run a servlet application using Tomcat5.5 ...
where to place the class path......and how to run....
After compiling Java file I have placed .class file in ...
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes
and my java file is in...
C:\servlets/HelloWorld.java
and i have accessed like this....
http://localhost:8080/servlet/HelloWorld
i m getting error like this.......
HTTP Status 404 - /servlet/HelloWorld
type Status report
message /servlet/HelloWorld
description The requested resource (/servlet/HelloWorld) is not available.
Apache Tomcat/5.0.25
Can anyone suggest a solution to this.........
Did you created the web.xml file ? Create a file
and make entries like this
save it in WEB-INF and now start the tomcat.
Access the URL http://localhost:8080/YourServletName
and make entries like this
JSP Syntax (Toggle Plain Text)
<servlet> <servlet-name>Name of your servlet</servlet-name> <display-name>bla bla</display-name> <servlet-class>Your calss name</servlet-class> </servlet> <servlet-mapping> <servlet-name>Your servlet name</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
save it in WEB-INF and now start the tomcat.
Access the URL http://localhost:8080/YourServletName
•
•
Join Date: Apr 2007
Posts: 5
Reputation:
Solved Threads: 0
hello sir ......
even though i have created theweb.xml...
its not running..
same error is occuring...
even though i have created theweb.xml...
its not running..
same error is occuring...
•
•
•
•
Did you created the web.xml file ? Create a file
and make entries like this
save it in WEB-INF and now start the tomcat.JSP Syntax (Toggle Plain Text)
<servlet> <servlet-name>Name of your servlet</servlet-name> <display-name>bla bla</display-name> <servlet-class>Your calss name</servlet-class> </servlet> <servlet-mapping> <servlet-name>Your servlet name</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
Access the URL http://localhost:8080/YourServletName
in url-pattern tag you have to give your servlet name after / ... i.e. /servlet/test
try with this URL http://localhost:8080/servlet/test
you are doing some mistake in assigning proper path or name.
try with this URL http://localhost:8080/servlet/test
you are doing some mistake in assigning proper path or name.
•
•
Join Date: Mar 2007
Posts: 83
Reputation:
Solved Threads: 2
First of all, it doesn't matter what you did with the .java file... Tomcat really cares about the servlet .class file
You have to tell Tomcat what you call your servlet within the web.xml file... and what the .class file is... this need to have the package.classname if you used a package... then in the servlet mapping you say which servlet, by name, you mapping to, and you have to give a "pattern" to match.... if you want to use the helloworld name you need to specify the helloworld name in the url pattern...
Or you can make sure the default servlet context is on, if all you want to do is test for learning the sevlets stuff, then you can place your servlet under the proper location and access them via localhost:8080/servlet/helloworld
the default servlet setting is for testing servlets, if you try to use that url "/servlet/helloworld" but you don't have the .class in the default servlet location, it will not run... basically the default servlet look s at the patch after "/servlet/" and tries to find a .class file with that name... if it finds it, it runs it... if not, it shows the error... BUT the default servlet is disabled by default on Tomcat 5.5 I believe, and you would need to enable it.... You can't use that for your application if you have placed it in any other location... this is well commented in the Tomcat config files...
I appologise if my comments are bit off in terminology, I don't have the Tomcat stuff sitting here to check, and I am in Japan so I have to translate much of this stuff roughly from the Japanese terminology we use daily to the English terms... sometimes the translations are not close enough...
Peace,
Post you web.xml and I will take a look at it...
You have to tell Tomcat what you call your servlet within the web.xml file... and what the .class file is... this need to have the package.classname if you used a package... then in the servlet mapping you say which servlet, by name, you mapping to, and you have to give a "pattern" to match.... if you want to use the helloworld name you need to specify the helloworld name in the url pattern...
Or you can make sure the default servlet context is on, if all you want to do is test for learning the sevlets stuff, then you can place your servlet under the proper location and access them via localhost:8080/servlet/helloworld
the default servlet setting is for testing servlets, if you try to use that url "/servlet/helloworld" but you don't have the .class in the default servlet location, it will not run... basically the default servlet look s at the patch after "/servlet/" and tries to find a .class file with that name... if it finds it, it runs it... if not, it shows the error... BUT the default servlet is disabled by default on Tomcat 5.5 I believe, and you would need to enable it.... You can't use that for your application if you have placed it in any other location... this is well commented in the Tomcat config files...
I appologise if my comments are bit off in terminology, I don't have the Tomcat stuff sitting here to check, and I am in Japan so I have to translate much of this stuff roughly from the Japanese terminology we use daily to the English terms... sometimes the translations are not close enough...
Peace,
Post you web.xml and I will take a look at it...
![]() |
Similar Threads
- double boot for running two operating systems (Windows NT / 2000 / XP)
- Running Tomcat on a webserver? (Java)
- Internet Explorer Running SLOW (Web Browsers)
Other Threads in the JSP Forum
- Previous Thread: Creatin table in JSP
- Next Thread: how to call javabean from jsp
| Thread Tools | Search this Thread |
apache backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial update video web





