Question on Running Servlet on a Web Server

Hi,
I got an example servlet here:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorldServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<head>");
out.println("<title>Hello World!</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World!</h1>");
out.println("</body>");
out.println("</html>");
I compiled this into HelloWorldServlet.class and sent it to a web server. How can I use a web browser to check if it is running on the web server? I am supposed to see "Hello World" in my browser, right?
Do I need to run J2EE server on the web server?
Many thanks in advance.
yaol

Must to have Apache Tomcat. Take a look at http://www.webmasterbase.com/article/305 .

Similar Messages

  • Running Servlet with J2EE Web Server

    Hi experts
    My web server is J2EE. I have compiled the servlet classes and have put them in the web-inf/classes directory. I have also declared the servlets in the web.xml file in the web-inf directory.
    When I run this, it gives error HTTP Status 404 - /fijidirectory.
    Experts can you help me with this pliz.
    Deepak

    Now the code looks like this.
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      <display-name>J2EE Servlet Config</display-name> 
      <servlet>
        <servlet-name>dirinterface</servlet-name>
        <servlet-class>DirectoriesInterface.DirInterface</servlet-class>
      </servlet>
      <servlet>
        <servlet-name>dispplaydirinfo</servlet-name>
        <servlet-class>DirectoriesInterface.DispplayDirInfo</servlet-class>
      </servlet>
      <servlet>
        <servlet-name>fijidirmain</servlet-name>
        <servlet-class>DirectoriesInterface.FijiDirMain</servlet-class>
      </servlet>
      <servlet>
        <servlet-name>whitedirinterface</servlet-name>
        <servlet-class>DirectoriesInterface.whiteDirInterface</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>dirinterface</servlet-name>
        <url-pattern>/FijiDirectory</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>dispplaydirinfo</servlet-name>
        <url-pattern>/dirInfo</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>fijidirmain</servlet-name>
        <url-pattern>/fiiidirectory</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>whitedirinterface</servlet-name>
        <url-pattern>/whfd</url-pattern>
      </servlet-mapping>
    </web-app>
    The url that I am using to access the system is: http://localhost:8080/whfd

  • Do i need a network card to install and run a local java web server

    Friends,
    Do i need a network card in my computer to install and run a local Java Web Server or any Web Server.

    network cards are only for connecting equipment together... you can set up a webserver without any more equipment than you have already! Indeed Tomcat... BUT you would be better off with apache for production stuff. It depends what you need to serve... if its mainly static pages (i guess it probably isn't) then apache will be enough by itself; but if you need to serve dynamic pages (JSP, Servlet blah blah) then you will need tomcat. Tomcat has it's own webserver and its perfectly ok for testing or low-load stuff, but you can integrate with Apache (a moderately compex task, but do-able, see tomcat-user forum off of apache site) for greater stability, and you don't have to show the port in the URL... Don't set up a webserver on any pc that contains stuff you don't want hacked into... it becomes very succeptible when the service is up...

  • Could not load servlet information from web server

    I am trying to register a servlet through the web object manager.
    As soon as click the web object manager menu pick I get the following
    error: Could not load servlet information from web server.
    On other peoples machines here it works fine and they can register
    servlets. What am I missing!

    You must be using Jdev 3.2.x, this is a known bug. In Jdev 9.0.2 we use the standard J2EE web.xml in order to register servlets. You should consider moving to the new IDE.

  • Global data in a servlet using iPlanet Web Server

    Our configuration is an Applet->Servlet->JNI->C/C++ code.
    We have C code that does a number of lengthy mathematical calculations. This C code not only uses its own global variables but, it is also comprised of numerous subroutines that all call each other, reading and writing global C variables as they go. These globals are all isolated to the C code shareable object (.so) library that is included using the LoadLibrary call when the servlet is initialized.
    The problem is that in a multi-user environment (3-5 simultaneous users) we need to have each user have their own "copy" of the servlet (and the C code) so that users will not be accessing each other's global data. We can NOT have only one copy of the C code and define it as synchronized because the calculations that are performed can take a very long time and we can not hold off user requests while the firs user finishes.
    Our hope is that there is a way to configure the iPlanet Web server such that each new user that starts up a copy of the Applet/Servlet combination will get their own "space" so that they can work independently of any other user. We have at most 20 users of this system and only 3-5 simultaneous users so we should not have a problem with memory or CPU speed.
    If anyone has a solution, I would greatly appreciate it!

    The C library is shareable. But you don't want it to be shared. That's your question summarized, isn't it?
    You probably can't prevent it from being shared, so to prevent multiple use of it you would have to queue up the requests to be done one at a time. WynEaston's suggestion of having the servlet implement SingleThreadModel would help, but I believe the servlet spec allows servers to run multiple copies of a servlet that does that (as opposed to running a single copy in multiple threads).
    Your other alternative is to rewrite the math in Java, or at least in some object-oriented language where you don't need global variables (which are the source of your problem). All right, I can already hear you saying "But that wouldn't be as fast!" Maybe not, but that isn't everything. Now you have a problem in queueing theory: do you want a single server that's fast, but jobs have to wait for it, or do you want multiple servers that aren't as fast, but jobs don't have to wait? That's a question you would have to evaluate based on the usage of your site, and it isn't an easy one.

  • Problem running XSQLSERVLET on JAVA WEB SERVER

    THE BELOW LISTED SIMPLE XSQL QUERY WHEN RUN ON JAVA WEB SERVER 2 (WITH CLASSPATH/MAPPING SETTING AS IN INSTALLATION MANUAL) GIVES FOLLOWING ERROR:
    1. XML document must have a top level element.
    <?xml version="1.0" encoding="UTF-8"?>
    <xsql:query xmlns:xsql="urn:oracle-xsql" connection="demo">
    SELECT 'Hello World' AS "GREETING" FROM DUAL
    </xsql:query>
    2. WHILE RUNNING INDEX.HTML FILE FROM JAVA WEB SERVER 2 IT GIVES FOLLOWING ERROR
    Oracle XSQL Servlet Page Processor 1.0.4.3 (Production)
    XSQL-017: Unexpected Error Occurred
    java.lang.IllegalArgumentException: sun.io.ByteToCharUTF-8
    at sun.io.ByteToCharConverter.getConverterClass(ByteToCharConverter.java:79)
    at sun.io.ByteToCharConverter.getConverter(ByteToCharConverter.java:109)
    at java.lang.String.(String.java:294)
    at java.lang.String.(String.java:313)
    at oracle.xml.xsql.XSQLUtil.XL(XSQLUtil.java:207)
    at oracle.xml.xsql.XSQLServletPageRequest.getParameter(XSQLServletPageRequest.java:139)
    at oracle.xml.xsql.XSQLActionHandlerImpl.variableValue(Compiled Code)
    at oracle.xml.xsql.XSQLActionHandlerImpl.getAttributeAllowingParam(Compiled Code)
    at oracle.xml.xsql.actions.XSQLIncludeXSQLHandler.init(XSQLIncludeXSQLHandler.java:46)
    at oracle.xml.xsql.XSQLDocHandler.handlerForAction(XSQLDocHandler.java:283)
    at oracle.xml.xsql.XSQLDocHandler.getDocument(Compiled Code)
    at oracle.xml.xsql.XSQLPageProcessor.process(Compiled Code)
    at oracle.xml.xsql.XSQLServlet.doGet(XSQLServlet.java:60)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:715)
    at javax.servlet.http.HttpServlet.service(Compiled Code)
    at com.sun.server.ServletState.callService(Compiled Code)
    at com.sun.server.ServletManager.callServletService(Compiled Code)
    at com.sun.server.ProcessingState.invokeTargetServlet(ProcessingState.java:423)
    at com.sun.server.http.HttpProcessingState.execute(HttpProcessingState.java:79)
    at com.sun.server.http.stages.Runner.process(Runner.java:79)
    at com.sun.server.ProcessingSupport.process(Compiled Code)
    at com.sun.server.Service.process(Service.java:204)
    at com.sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.java:374)
    at com.sun.server.http.HttpServiceHandler.handleRequest(Compiled Code)
    at com.sun.server.HandlerThread.run(Compiled Code)
    null

    What jdk are you using ?
    I had this problem with 1.1.7

  • Putting a helloword.java code to run on Sun Java Web Server

    Hello,
    Given helloworld.jsp:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorld extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse res)
                   throws ServletException, IOException {
         res.setContentType("text/html");
         PrintWriter out = res.getWriter();
         out.println("<HTML>");
         out.println("<HEAD><TITLE>Hello World</TITLE></HEAD>");
         out.println("<BODY>");
         out.println("<H1>Hello World</H1>");
         out.println("Today is: " + (new java.util.Date().toString()) );
         out.println("</BODY></HTML>");
    } // doGet
    } // HelloWorld
    How can I put this code to run on Sun Java System Web Server, how to compile this ? what and how to put in the webserver document and how to access it ?
    Thanks for verbose and basic information about this, appreciated...

    What you wrote is not a JSP. It is a Java Servlet.
    You need to compile it. That creates HelloWorld.class.
    Create a directory say hello. You need to create a directory structure as mentioned below.
    hello|
    WEB-INF|
    web.xml
    classes|
    HelloWorld.class
    You need to package it in a war (web archive) file.
    %cd hello
    %jar cvf hello.war .
    Then deploy this war file using admin GUI or wadm CLI.
    I would suggest using Netbeans IDE to create the web application.
    To deploy the war file on SJS web server 7 update 2, see my blog at
    http://blogs.sun.com/kmeduri/entry/how_to_deploy_a_war

  • How to publish a servlet class to web server?

    background:
    web server: tomcat apache 4
    context path: webapp\test\
    servlet path: webapp\test\WEB-INF
    servlet name: HelloWorld.class
    i tried to placed the servlet class file to above servlet path,
    but i can't invoke the servlet by http://localhost:8080/test/HelloWorld
    what should i do in order to invoke the servlet at browser?
    Is a web.xml necessary a must to provided a mapping between request name and actual class name?

    First of all you need a *.war structure which look like this
    /app-name
    /app-name/WEB-INF/
    /app-name/WEB-INF/lib
    /app-name/WEB-INF/classes
    When you have created this structure you add your servlet (HelloWorld.class) in the classes directory (Create the package structure first).
    When this is done you need to map the servlet to a given uri which is done in the web.xml. An example is found below:
    <servlet>
    <servlet-name>hello</servlet-name>
    <servlet-class>package.HelloWorld</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>hello</servlet-name>
    <url-pattern>/hello/*</url-pattern>
    </servlet-mapping>
    Hopefully this will help :-)
    best regards
    Stig

  • How to run Naming service in WebAs server using telnet

    Hi
       i have a requirement to start a naming service in WebAs server.I have seen all the services running in server using telnet.But i haven't find naming service.So i have to start it.so pls send me the command and the way how to start it.

    Hello Bhogi,
    The naming service is a core service so it should always be started. You can check it via telnet using lss command on the server shell or in the visual administrator if you navidate to server-> services -> JNDI Registry.
    I suspect that you have not seen the naming service via telnet as you were on the dispatcher node instead of on the server.
    Best Regards
    Vyara

  • Getting errors while running jsp on sunone web server 6.1

    While i created war file and delpoyed my application on web server6.1, it loads default jsp(welocme.jsp) page fine. but when I submit data it gives me following error.
    [06/Oct/2003:09:17:53] info ( 600): Internal Info: loading servlet /custapprec/bonus.jsp
    [06/Oct/2003:09:17:58] info ( 600): JSP: JSP1x compiler threw exception
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    C:\iPlanet\Servers\https-NVS06S-W2K.abc.com\config\..\ClassCache\_jsps\_custapprec\_bonus_jsp.java:63: Class myBean.BonusBean not found.
    myBean.BonusBean Bonus = null;
    ^
    C:\iPlanet\Servers\https-NVS06S-W2K.abc.com\config\..\ClassCache\_jsps\_custapprec\_bonus_jsp.java:65: Class myBean.BonusBean not found.
    Bonus= (myBean.BonusBean)
    ^
    C:\iPlanet\Servers\https-NVS06S-W2K.abc.com\config\..\ClassCache\_jsps\_custapprec\_bonus_jsp.java:69: Class myBean.BonusBean not found.
    Bonus = (myBean.BonusBean) Beans.instantiate(this.getClass().getClassLoader(), "myBean.BonusBean");
    ^
    C:\iPlanet\Servers\https-NVS06S-W2K.abc.com\config\..\ClassCache\_jsps\_custapprec\_bonus_jsp.java:73: Variable Bonus may not have been initialized.
    pageContext.setAttribute("Bonus", Bonus, PageContext.PAGE_SCOPE);
    ^
    4 errors, 1 warning
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
         at com.iplanet.server.http.servlet.NSServletEntity.load(NSServletEntity.java:252)
         at com.iplanet.server.http.servlet.NSServletEntity.update(NSServletEntity.java:173)
         at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:427)
    [06/Oct/2003:09:17:58] warning ( 600): Internal error: Failed to get GenericServlet. (uri=/custapprec/bonus.jsp,SCRIPT_NAME=/custapprec/bonus.jsp)
    anybody can please help me with this error?
    Thanks

    Your stack trace indicates classes that are not part of Sun ONE Web Server 6.1 (e.g. com.iplanet.server.http.servlet.NSServletEntity) but are classes in earlier releases of the web server. It looks like your web application contains classes or .jar files that contain an older implementation of the JSP engine from a previous web server release. Remove these and give it another try.

  • I have perl scripts that I want to be able to run with my iplanet web server 6.0. How can I make it work in Windows NT? (Because I have no problem when I use it with Linux).

     

    Hi Melanie,
    In order to run a PERL script under Windows NT the iPlanet Web Server needs to know where to find the PERL interpreter.
    follow these steps :
    1) Make sure Windows NT knows what a .pl file is. In file Manager click on file and choose associate from the menu. Check the "files with extension" drop-down list for pl - if it exists verify that it is pathed to your perl.exe. If it is not already on the list click the "New Type" button. In the Filetype box put pl. Choose open from the Action drop-down list. In the Command box specify the full path to your perl.exe interpreter (Make sure to use short filenames, rather than long filenames.) Click the OK button. Then click the Close button in the main Associate dialog box. Double click a .pl file to test - it should automatically launch the PERL interpreter and feed it your .pl file.
    2) Create a directory to contain your .pl scripts.
    ~server_root\shell-cgi is a good choice.
    or \cgi-bin\
    NOTE: Make very sure that this directory is NOT part of the document root, it should have it's own directory (preferably at the same level of the docroot).
    3) In the Admin Server select Programs.
    4) Choose CGI directory (normally) or WinCGI directory or ShellCGI Directory depending on ur choice from the Programs menu.
    5) Put the URL Prefix you would like to map to your Shell-CGI directory into the URL Prefix field.
    6) Put the full path to your Shell-CGI directory in the Shell CGI directory field.
    7) Click OK.
    8) The save and apply changes page will display your changes and give you the opportunity to verify them. If they are correct click the Save and Apply button. If not Click the Undo button and go back to step 4.
    (9)You can then call your .pl scripts directly by referencing the directory mapping that you have just created. For example:
    http://my.server.whatever/shell-cgi/ myscript.pl
    this should work now.
    If not Pls Mail me.
    regards
    T.Raghulan
    [email protected]

  • Run form letter from web server

    Has anyone been able to design and run a form letter report in html. When I try to run it, it is always blank. I would like to run it as a .jsp.

    Hi,
    The form letter report is applicable only for paper layout. It is not applicable for web layout.
    However, you can generate to html/htmlcss output from web server using the following command.
    http://server:port/reports/rwservlet?server=<server_name>&destype=cache&desformat=html/htmlcss&userid=<connection_string>
    regards,
    Senthil

  • Problem running Forms on Oracle Web Server 3.0

    I have implemented Developer/2000 forms on Oracle Web Server 3.0 (Non Cartridge Implemetation). Whenever there are multiple client request for the form, Forms server raised the Dr watson error (windows NT 4.0).
    Kind request to anybody who has solution for the above.

    Someone got the same message on a Suse 6.0. On a redhat 5.x, the
    required files (libraries) are in packages
    libstdc++-2.8.0-8
    libstdc++-devel-2.8.0-8 (? may not be necessary)
    You can get the above packages on redhat ftp and mirror sites.
    Again, oracle on linux is really "RedHat-ish"!!!
    Robert Xu
    lin (guest) wrote:
    : After I installed Oracle Web server on turbo linux,
    : I started owsctl wrb, and got error message
    : libstdc++s0.2.8.
    : I did a find from root to search this file, but not found.
    : anyone can help me.
    : thanks
    null

  • Viewing servlet data on web server

    Hello, i have this servlet code snippet that gets data posted to it from an application. I know it gets the data because when i call the getInputStream() method on the connection to the servlet in the application, i can see the posted data. But my problem is that i would like to see the data displayed on the servlet web page when i call it (i.e. like when you do a submit in a web form and enter the servlet URL to which you have submitting the form data, the URL displays the form data you have just submitted).
    In my case, when i enter the servlet URL in my browser, i get the " HTTP Status 405 - HTTP method GET is not supported by this URL" error message.
    your help with this problem will be much appreciated.
    The servlet code is:
    public void doPost(HttpServletRequest req, HttpServletResponse resp) {
            try {
                int len = req.getContentLength();
                byte[] input = new byte[len];
                ServletInputStream sin = req.getInputStream();
                int c, count = 0 ;
                while ((c = sin.read(input, count, input.length-count)) != -1) {
                    count +=c;
                sin.close();
                String inString = new String(input);
                int index = inString.indexOf("=");
                if (index == -1) {
                    resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                    resp.getWriter().print(message);
                    resp.getWriter().close();
                    return;
                String value = inString.substring(index + 1);
                //decode application/x-www-form-urlencoded string
                String decodedString = URLDecoder.decode(value, "UTF-8");
                 String reverseStr = (new StringBuffer(decodedString)).toString();
                resp.setContentType("text/html");
                PrintWriter out = resp.getWriter();
                out.println("<HTML>");
                out.println("<HEAD><TITLE>Hello, " + reverseStr + "</TITLE></HEAD>");
                out.println("<BODY>");
                out.println("Hello, " + reverseStr);
                out.println("</BODY></HTML>");
            } catch (IOException e) {
    }

    I don't think you have a problem. Since you've implemented the POST method, you're going to be submitting your data from an HTML form. So just write some HTML that does that request for you. That's how it's supposed to work. Don't bother trying to make workarounds for ways it isn't supposed to work anyway.

  • Java Web Server 2.0 to Tomcat 3.2

    My company was running servlets using Java Web Server on Solaris and I want to switch to Tomcat 3.2. The installation was fairly simple but I can't figure out how to deploy my previous servlets on Tomcat. Under Java Web Server, all my apps were in the /servlets folder. What is the quickest and easiest way to do this?

    For Tomcat you place them in the /jakarta-tomcat-3.2.1/webapps folder. Each directory under webapps represents a different project. Let's say you have all your servlets grouped together in one directory. You'd make a directory (I'm assuming your root Tomcat directory is /jakarta-tomcat-3.2.1):
    /jakarta-tomcat-3.2.1/webapps/myprojects/web-inf/classes
    and place all your .class files in the classes folder. To access "myServlet", the browser will read (I assume Tomcat is on port 8080):
    http://myserver.com:8080/myprojects/servlet/myServlet
    Hope this helps.
    Michael Bishop

Maybe you are looking for