Wrox Home  
Search P2P Archive for: Go

  Return to Index  

j2ee thread: Problem with calling of servlet from browser??


Message #1 by bikashpaul_2001@y... on Tue, 4 Jun 2002 06:21:36
Hi

Firstly, I think you might have a problem if your folder was really called
Web-inf since most containers _require_ WEB-INF all caps. I've sent you a
war file to your personal email address. If you put it in public_html and
start the server, you should get a blank page when you go to

http://localhost:8080/simple/

If you get a 404 message then I am not sure what to suggest - you may be
using so old a server that nothing I know applies because its relevance
expired before I started computing. If it doesnt work, then I think you
might have to consider downloading another servlet container instead,
perhaps tomcat 4

Now, if you navigate to the following address, then you should get a
response. What I did was, the following. I copied and pasted, saved and
compiled you servlet. And then created a folder called simple with the
following contents

public_html/
    /simple/
        index.html
        /WEB-INF/
            web.xml
                /classes/
                    SimpleServlet.class

web.xml has the following contents:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
  <servlet-name>SimpleServlet</servlet-name>
  <servlet-class>SimpleServlet</servlet-class>
</servlet>
</web-app>

I then navigated to:

http://localhost:8080/simple/servlet/SimpleServlet

And got the expected result.

chanoch


----- Original Message -----
From: "Bikash Paul" <bikashpaul_2001@y...>
To: "Java 2 Enterprise Edition" <j2ee@p...>
Sent: Friday, June 21, 2002 7:31 AM
Subject: [j2ee] Re: Problem with calling of servlet from browser??


> Hi canoch,
> I have one simple servlet and this is only print one
> message and I want to deploy this servlet in j2ee
> server and want to call this servlet from browser
> through url thats all nothing else. Iam not trying to
> add ejb in this servlet.Below is my code of
> SimpleServlet:-
>
> import java.io.*;
> import java.util.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class SimpleServlet extends HttpServlet
>  {
>  public void doGet(HttpServletRequest req,
> HttpServletResponse res)
>  throws ServletException, IOException
>                {
>                  res.setContentType("text/html");
>                  PrintWriter out = res.getWriter();
>                  out.println("This is only for test");
>                }
>  }
> Regards
> Bikash
>
> --- chanoch <mail@c...> wrote:
> > My question is this web.xml file is created by
> > server itself during
> > > deployment then if I modified it manually Is it
> > work?
> >
> > yes, if you modify the file it should work. I modify
> > my web.xml as mentioned
> > previously and it works
> >
> > > My j2ee server created web.xml file in
> >
> "c:\j2sdkee1.2.1\public_html\servlet\Web-inf\web.xml".
> >
> > there is a problem with giving a context root of
> > servlet since servlet is
> > mapped on many systems to call a servlet... Its a
> > bit like CGI-BIN - you
> > wouldnt want to call you application CGI-BIN because
> > it normally means that
> > a CGI program is going to be run so the server and
> > other people might get
> > confused. Usually, the call
> >
> > context/servlet/name
> >
> > is translated into the servlet is the classes or
> > servlets folder with the
> > name, "name" as specified in the web.xml file.
> >
> > > I gave context root name "servlet" .
> >
> > my thoughts are change this to something less
> > confusing. I have deployed in
> > j2ee server but not using a wizard as you seem to
> > have done (i didnt even
> > know that was possible. I did it via a .war file. If
> > you are really stuck,
> > please send me all your files, I will get it set up
> > on my system and then
> > send it to you as a war file and you can see what
> > I've done - a war file is
> > guaranteed to work on your system.
> >
> > chanoch
> >
> > My doubt in the
> > > process of deployment of servlet I skiped
> > "Aliases"
> > > dialog box Is it require any aliases?Have u
> > deployed
> > > any simple servlet in j2ee server?Plz help me to
> > slove
> > > this prblem Iam facing this problem for 2 weeks
> > but
> > > still I don't get any perfect solution.Waiting for
> > ur
> > > reply.
> > >
> >
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
>


  Return to Index