Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to invoke servlet in J2EESDK 1.4

Status
Not open for further replies.

SUR803

Programmer
Feb 18, 2004
2
GB
Hi All,
I have downloaded the j2eesdk-1_4-dr-windows-eval.exe software.
Then I have written the following Servlet as my first servlet ever:
--------------------------------------------------------------------------
package hall;

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

public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello World");
}
}
-----------------------------------------------------

I have compiled the above code and made HelloWorld.class in the directory D:<mydir>/hall/HelloWorld.class.

Then I packaged the class using deploytool (which came with the downloaded software) as web component. In doing so i specified the context root as /hall.
Now if I want to view the servlet using ' in IE it is giving the error
'HTTP Status 404-/hall.HelloWorld/'
'Requested resource( /hall.HelloWorld/)not available.'

But all the applications(e.g. hello) that are explained in the documentation of the software are visible from the browser following the instructions given in the documentation.

I am pretty new to Web technology.
Please help me! Where I am doing wrong.
Thanks a lot for your help
 
Just to get back to basics ... are you planning on using full J2EE server capablities (ie JMS, EJB and so on) or just looking into using servlets/JSP ?

If the latter, then you may well do better in using a servlet container such as Tomcat, rather than a full blown J2EE server ...

In either case though, your problem will be due to an XML config file, within the servlet container named web.xml. Can you post your web.xml config ?
 
Thanks a lot sedj.
Yes I want to use full J2EE server capabilities.This is just my starting point.Anyway the web.xml file I am using(generated by the Deploytool) as below:
---------------------------------
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<web-app version=&quot;2.4&quot; xmlns=&quot; xmlns:xsi=&quot; xsi:schemaLocation=&quot; <display-name>HelloWorld1</display-name>
<servlet>
<display-name>HelloWorld</display-name>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>hall.HelloWorld.class</servlet-class>
</servlet>
</web-app>
---------------------------------------

Please note that as I already created the package and deployed once in Deploytool, when I deployed it again it was named as HelloWorld1 as seen in the above .xml file.

But I could not resolve the problem.
Thanks in advance for your help.
 
You need a servlet-mapping such as :

<servlet-mapping>
<servlet-name>HelloWorld1</servlet-name>
<url-pattern>/servlet/HelloWorld1</url-pattern>
</servlet-mapping>

This goes after the </servlet> tags.

You can then access it like :

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top