Java servlet programming

I am the beginner. So would you tell me what should I begin with? what should I need, and how should I do?
What does this "http:/localhost:8080/servlet/Hello" means?
Where can I identify the server and the port number?
Thanks a lot!

http:/localhost:8080/servlet/Hello
it means
http:// protocal
localhost: ur current machine
8080 the port no which we give at installation time
servlet alies name for servlets folder which is recide webserver directory
hello servlet class name
u just try this
1)install first j2sdk1.4.0 (or) later
ex:
c:\j2sdk1.4.0
2)install second tomcat5.0
ex:
c:\tomcat5.0
3) place the cursor on mycomputer and right click properties --> advance
     |
     environment (click this)
     |
     new
     |
     JAVA_HOME c:\j2sdk1.4.0 (ok,ok)
     new
     |
     CATALINA_HOME c:\tomcat5.0
     click path
     |
     (add at end) ;c:\j2sdk1.4.0\bin;c:\tomcat5.0\bin;
     new
     |
     CLASSPATH %classpath%;.;c:\tomcat5.0\common\lib\servlet-api.jar;
     now u restart the computer (or) tomcat server
     then in browser
     http://localhot:8080

Similar Messages

  • Inputting an excel file to the java servlet program

    Hi,
    How can I input an excel file into the java servlet program? I am using POI HSSF programming to read the content of that excel file.I have created a form that will accept the path from the user and in the servlet program, I have called a post method to retrieve the path of the file. I am getting the path of the file as a string.Then I have to access the file to read the data. But it is not working. What should I do?.Please help me.
    I have created an html file to create a form that will ask the path of the file to be loaded into the servlet program.Please give me a solution,thanks in advance. The servlet program that receives the file is shown below. It just only take the name of the file and prints if that is ok.
    <html>
    <body bgcolor="green">
    <center>
    <form method="post"  action="http://localhost:8080/examples/servlet/Ron1">
    <table>
    <tr>
    <td><B>ENTER THE PATH OF THE FILE</td>
    <td><input type=file name="path"></td>
    </tr>
    </table>
    <input type=submit value= "submit" >
    </form>
    </body>
    </html>
    import java.io.*;
    import javax.servlet.*;
    import java.lang.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.text.*;
    import java.util.*;
    import com.oreilly.servlet.MultipartRequest;
    import org.apache.poi.hssf.usermodel.*;
    public class Ron1 extends HttpServlet
       public void doPost(HttpServletRequest request, HttpServletResponse response)   throws IOException, ServletException
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            String u = request.getParameter("FileToUpload");
            out.println("The Path is "+u);
            System.out.println("The path is "+u);
            MultipartRequest multi = new MultipartRequest(request,u,10 * 1024 * 1024);
            System.out.println("path is "+u);
            Enumeration files = multi.getFileNames();
            File fUploadedFile = null;
            String sFileName = "";
            out.println("path is "+u);
            while(files.hasMoreElements())
                            String name = (String)files.nextElement();
                            out.println("file is "+name);
                            sFileName = multi.getFilesystemName(name);
                            String type = multi.getContentType(name);
                            fUploadedFile = multi.getFile(name);
                    FileInputStream fis= new FileInputStream(fUploadedFile);
                   HSSFWorkbook wb=new HSSFWorkbook(fis);
                    System.out.println("The path is "+u);
                    out.println("File has identified successfully\n");
                    out.close();
       }

    Hi,
    Can you try to use classes from java.net package (URL, URLConnection) to pass the contents of excel file to servlet?
    HTH
    Vishal

  • Example of 'Java Servlet Programming, 2nd Edition' (O'reilly)

    Hi,
    I'm reading 'Java Servlet Programming, 2nd Edition' (O'reilly).
    I got a error "'.' expected" and "cannot resolve symbol"
    when trying JSP sample, hello3.jsp and HelloBean.java:
    I put hello3jsp to webapps/sample, and HelloBean.class
    to webapps/sample/WEB-INF/classes .
    Is this collect? If true, why I got the error?
    Could you give me any advices?
    hello3.jsp:
    (http://www.servlets.com/jservlet2/examples/ch18/hello3.jsp.txt)
    <%-- hello3.jsp --%>
    <%@ page import="HelloBean" %>
    <jsp:useBean id="hello" class="HelloBean">
      <jsp:setProperty name="hello" property="*" />
    </jsp:useBean>
    <HTML>
    <HEAD><TITLE>Hello</TITLE></HEAD>
    <BODY>
    <H1>
    Hello, <jsp:getProperty name="hello" property="name" />
    </H1>
    </BODY>
    </HTML>HelloBean.java:
    (http://www.servlets.com/jservlet2/examples/ch18/HelloBean.java)
    public class HelloBean {
      private String name = "World";
      public void setName(String name) {
        this.name = name;
      public String getName() {
        return name;
    }Error Message:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 4 in the jsp file: /hello3.jsp
    Generated servlet error:
        [javac] Compiling 1 source file
    /usr/local/java/jakarta-tomcat-4.1.18/work/Standalone/localhost/sample/hello3_jsp.java:7: '.' expected
    import HelloBean;
                    ^
    /usr/local/java/jakarta-tomcat-4.1.18/work/Standalone/localhost/sample/hello3_jsp.java:44: cannot resolve symbol
    symbol  : class HelloBean
    location: class org.apache.jsp.hello3_jsp
          HelloBean hello = null;
          ^regards
    maco

    I got succeeded!
    I changed the three point:
    * add 'package hoo;' in HelloBean.java
    * add '<%@ page import="my.HelloBean" %>' in hello3.jsp
    * change '<jsp:useBean id="hello" class="HelloBean">
    to '<jsp:useBean id="hello" class="my.HelloBean">
    Before posting, I searched google three times but couldn't get answer.
    I could not get well if you didn't give me help...
    Thank you very much.

  • Application Server 4.0 caching the Java Servlet Program

    Hi all,
    I am working with Oracle8i databse and Oracle Application Server 4.0. Now I need to develop some Java Servlet's Program. I successful configure the server and my Servlet program can connect to the Oracle database.
    However, when I make some modification to the program and recompile it. The browser cannot refresh to the modified program. This mean that the content is't update. I think the reason may be the previous program is cached in server.
    Later, I discover using the 'owsctl' utility to reload the application server can solve this problem. However, it is quite inconvenience and not favour to reloasd the server very frequently. And I guess there may have some configuration parameters in the 'OAS Manager' can help me to solve my problem.
    So, anyone can tell me how to solve this problem? Thank you very much.
    Regards

    OAS 4.0.8.1 supports servlets. You need a patch if you implement extra path info feature of servlets. In addition, you have to bounce OAS everytime you upload new servlets. This behavior does not follow the Servlet spec and I don't know when Oracle will fix it. It is a big problem for sites trying to run 24x7.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by dlnoida:
    Dear All,
    I have an application built in applets, i wants to host them on OAS 4.0.7.
    How can i do it if possible? Do i reqire any third party tool for it ?
    Is OAS 4.0.8 supports servlets?<HR></BLOCKQUOTE>
    null

  • Compiling java servlet programs

    i have Tomcat 5.0 and SDK 1.5 . I am able to compile java programs. But in servlet programs the compiler is unable to recognize the javax.servlet package(the code below). I have pushed all the JAR files of TOMCAT to the CLASSPATH . But nothing has changed.
    javax.servlet.*;
    javax.servlet.Http.*;

    hi,..
    javax.servlet.Http.*; should be javax.servlet.http.*; !
    even though you have put the jar files in the classpath .. does it point to servlet-api.jar ? if it does.. it should work. Also try out specifing the classpath using the -cp while compiling the servlet program .
    --Olakara                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Java servlet class access

    Can a servlet running on server A access a class defined on server B?
    More information:
    I am new at Java servlet programming and want to make sure that my web application is secure. I have set up a Java class that returns some user information (name, email address etc) and I have set up some jsp and servlet pages that access the class via an 'import my.class...' for servlets and a '@page import ="my.class..." 'for jsp. The jsp and servlet pages do session checking and authentication but the class does none of that - it's methods just return the requested data. I do not want to put any authentication in the class but I want to be certain that there is no way some other web server out on the internet could access this class in my web application. I do not think it is possible but my fear is that some hacker out there could somehow remotely do an @page import "my.class..." on my webserver and then gain access to my class methods? These web apps are running inside a Glassfish 3.0 app server.
    Thanks!

    user479480 wrote:
    That is very helpful info. I have been writing a lot of functional type code (updating, selecting and returning database data etc) inside Java servlets but when I get a new requirement I end up rewriting the same code in new servlet pages. So I have been thinking of putting all of that functional code in classes that I can re-use but was unsure of the security access and did not want to clutter the classes up with a bunch of session/authentication checking.
    Do you recommend any books on J2EE Web programming? Thanks again for your assistance.Code re-use isn't a problem that way, because you can put your common code into a library jar and use it in as many JVMs as you like. What you can't do is to access any Java objects running in one JVM from another one, whether or not they are on the same machine.

  • Java Servlet installation problem

    We have a Java Servlet program.
    To move into OAS.
    1.We need to configure the catridge(Done)
    2.We have to set the run time environment(I couldn't get this
    one)
    Oracle says two different methodology,
    1. From JDeveloper point of view
    2. From OAS point of view,
    I am not very clear in setting the environment variables and
    moving the files.
    Regards
    Nirmal
    null

    Hi,
    I think your problem has to do with your classpath. When compiling java classes, you must specify a classpath that the compiler will use to resolve your import statments. Since you are compiling a servlet, you must include the jar file that contains the javax.servlet package. Since you've installed the j2sdkee 1.3.1, you'll find the javax.serlvet package within the j2ee.jar file within the J2SDKEE 1.3.1 lib directory. So your javac command should look like this:
    javac -classpath <j2sdkee1.3.1 directory>/lib/j2ee.jar Test.java
    ( where j2sdkee1.3.1 directory is the path to where you installed the j2sdkee 1.3.1 ).
    I hope this helps?
    Cheers
    Jeff

  • Servlet program in eclipse

    hi all,
    i write simple hello servlet program in eclipse...
    but compiler tells " javax.servle.* " cannot be resolved...
    plz clarify how to run servlet program in eclipse as a tomcat webserver....
    import java.io.*;
    import javax.servlet.*;
    public class helloservlet extends GenericServlet{
         public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException
         response.setContextType("text/html");
         PrintWriter pw= response.getWriter();
         pw.println("hello servlet");
         pw.close();
    }regards
    machepalli

    hi,
    if you are using tomcat 5.5 server use jdk1.5 and if you use tomcat 5.0 use jdk1.4 then compatability adjust.And jar files to library go to tomcat-home ->common->lib->Servelet-api.jar file to your java program library.....
    And better to use myeclipse1.4 instead of eclipse ... bcoz sometimes it requires plugins to avoid that use myelipse1.4 ......

  • How to run servlet program in eclipse 3.1

    i run the jsp program in eclipse 3.1
    i want to run sample servlet program in eclipse, how to create the project,where to store the class file..? where to store the web.xml file..?
    plz give explanation with HelloWorld.java program....

    Install WTP and follow the basic J2EE WebApp Tutorial from their WTP tutorials page.

  • Problem in compiling aa servlet program

    I have installed jsdk1.4.2_13
    And also installed tomcat 5.0.28
    I have set
    CATALINA_HOME==C:\Program Files\Tomcat\jakarta-tomcat-5.0.28
    JAVA_HOME ==C:\j2sdk1.4.2_13
    CLASS_PATH==
    C:\Program Files\Tomcat\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar;
    C:\Program Files\Tomcat\jakarta-tomcat-5.0.28\common\lib\jsp-api.jar
    PATH ==C:\j2sdk1.4.2_13\bin;C:\Program Files\Tomcat\jakarta-tomcat-5.0.28\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
    -->My java programs are compiling
    -->I can run tomcat server , And also can see starting page of "http://localhost:8080/"
    But I am not able to compile servlet program
    MY sevlet program is
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String docType =
    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
    "Transitional//EN\">\n";
    out.println(docType +
    "<HTML>\n" +
    "<HEAD><TITLE>Hello</TITLE></HEAD>\n" +
    "<BODY BGCOLOR=\"#FDF5E6\">\n" +
    "<H1>Hello</H1>\n" +
    "</BODY></HTML>");
    ERRORS are:
    Pakage javax.servlet does not exist
    Pakage javax.servlet.http does not exist
    cannot resolve symbol HttpServletRequest
    and similar errors
    can anyone guide me?
    Message was edited by:
    Learn

    it's not CLASS_PATH, it's CLASSPATH.
    Directory paths with spaces in them are problematic. Surround them with double quotes.
    I think the best thing is not a CLASSPATH environment variable. Better to use the -classpath option on javac.exe when you compile.
    So your command to compile might look something like:
    javac -classpath .;"C:\Program Files\Tomcat\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar" *.java%

  • Location of java servlet (not jsp) deployed on Java Stack

    Hello,
    Why this forum? this post is related to the way of calling a java servlet deployed on the java stack, so it's related to the structure of the stack than to real java programming.
    Usually, I develop JSP servlets which are easily called either with a mapping or not. I have deployed now a java servlet and added a mapping to it by modifying the xml source itselft in its descriptor, but after deployement I am not able to reach the resource.
    In the windows explorer of the java stack I find in j2ee>cluster>server>apps my application as follows:
    app_ear>servlet_jsp>app>root>WEB-INF>classes>my class files
    app_ear>servlet_jsp>app>root>app.jsp
    This time it's not a jsp that I want to call: app/app.jsp but my java servlet which lies in the classes subdir.
    Could someone help my to achieve this or is it the wrong way, we can only request jsp applications?
    Kind regards,
    Tanguy Mezzano

    Hi Vladimir,
    here's my web.xml code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!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>WEB APP</display-name>
         <description>WEB APP description</description>
         <servlet>
              <servlet-name>SSORedirect3.jsp</servlet-name>
              <jsp-file>/SSORedirect3.jsp</jsp-file>
         </servlet>
         <servlet-mapping>
              <servlet-name>AuthenticatorServlet</servlet-name>
              <url-pattern>/SSOredirect3</url-pattern>
         </servlet-mapping>
         <security-constraint>
              <display-name>SecurityConstraint</display-name>
              <web-resource-collection>
                   <web-resource-name>WebResource</web-resource-name>
                   <url-pattern>/*</url-pattern>
                   <http-method>GET</http-method>
                   <http-method>POST</http-method>
              </web-resource-collection>
              <auth-constraint>
                   <role-name>DefaultSecurityRole</role-name>
              </auth-constraint>
         </security-constraint>
         <security-role>
              <role-name>DefaultSecurityRole</role-name>
         </security-role>
    </web-app>
    And in my jsp file, I have a form with this kind of code:
    <form name="xyz" method="GET" action="http://j2eeserver:50000/SSOredirect3/SSOredirect3">
    I get this error in my logs:
    com.sap.engine.services.servlets_jsp.server.exceptions.ServletNotFoundException: Requested resource [SSOredirect3/servlet/AuthenticatorServlet] not found.
    Exception id: [000C299F469E00650001D8E900000CCC000458E27823275B]#
    Best regards,
    Tanguy Mezzano

  • Problem Installing Java Servlets Package

    I downloaded a sample servlet program which imports classes from the Java Servlets Package. I have the JDK 1.2 which does not come with the servlet classes (javax.servlet and javax.servlet.http). So I then downloaded them from java.sun.com. They come as a set of class files in .zip format. I thought packages were supposed to be in .jar format? At any rate, my compiler still fails to see these classes even after I have extracted these files into the same directory as the original .zip file and added this directory to my classpath. Am I going about this the wrong way? Any ideas on how I can make my compiler see these classes? --Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I down loaded j2sdk 1.4 . and also down loade servlet package. I installed in bin directory.
    i took the sample program and compiled. there is error message " java servlet package not found.
    please help. email me at [email protected]
    Thanks
    sri

  • Unable to run Servlet program using J2EE SDK

    Hello,
    i am a newbie to all this j2ee stuff and servlets even.so the problem that i have maybe a very common one and i hope that most of you may have a fix to it...
    i use J2EE SDK to compile and run Servlet programs.I have a Servlet program with the class name defined as
    public class MyServlet extends HttpServlet ....
    the file is stored as MyServlet.java
    i set the CLASSPATH variable so that the required classes for the compilation of the program can be located.
    the program compiles without any glitches.
    However when i run the program by saying
    java MyServlet
    ( i dont think its any different to run servlet code is it?)
    i get the message
    java.lang.NoClassDefFoundException:MyServlet
    Can someone suggest a remedy?
    thank you
    -NDK

    First, I don't understand what you are trying to do. Running a servlet ?
    Servlets are ran by an application server ! (Apache Tomcat ....).
    Second, is your class in any package ?

  • Questions about Java Servlets and JSP

    Hi,
    I'm a confident Java Programmer (and really enjoy using this language) but am very new to Java servlets and Java Server Pages.
    I have previously worked with Perl on my web projects (simple 'league' style voting pages). I read in my 'Core Java' book that I should no longer use perl or even cgi.
    I need to know more about Java servlets and Java Server Pages so I can make the switch to a 'real' programming language.
    I have a few questions:
    How should I start to learn JS and JSP?
    How applicable will the java knowlegdge I have already be?
    Are JSP common on the world wide web?
    What tools do I need to start? (I currently develop in JBuilder and have Java 1.4.1 Standard Edition)
    Is it likey my web host (and others) will support JSP?
    Thank-you very much for helping a novice get started,
    Regards,
    Paul

    Hi, Steve ...has to be frustrating! But do not despair.
    Let's suppose the servlet it's named MyServlet on package org.servlets
    WEB-INF should look:
    WEB-INF
    classes
    org
    servlets
    MyServlet.class
    web.xml
    web.xml file should have this two declarations:
    <web-app>
      <servlet>
        <servlet-name>MyServlet</servlet-name>
        <servlet-class>org.servlets.MyServlet</servlet-class>
      </servlet>
      <!-- other servlets -->
      <servlet-mapping>
        <servlet-name>MyServlet</servlet-name>
        <url-pattern>/MyServlet</url-pattern>
      </servlet-mapping>
      <!-- other servlets mappings -->
    </web-app>Now, once the container starts (Tomcat?), you should be able to see that servlet in:
    http://localhost:8080/[my-context/]MyServletAnd what my-context is? The web application context. This string should be empty if your're deploying to the root context, otherwise should the context name. In Tomcat, deploying to root context defaults to using webapps/ROOT.
    Sorry for my English, but I felt the need to answer your request. I hope it helps despite my writing.

  • Help ~~ Cannot compile servlet program

    I have recently written a servlet program. When I compile the program (let's say "HelloWorld.java"), I've got the following error message:
    package javax.servlet does not exist
    I've download the class files and set the classpath already. Have I missed anything?
    Thx!

    I have recently written a servlet program. When I
    compile the program (let's say "HelloWorld.java"),
    I've got the following error message:
    package javax.servlet does not existyou donot have servlet api classes in your classpath
    I've download the class files and set the classpath
    already. Have I missed anything?just check the classpath again and compile.
    say echo CLASSPATH and see

Maybe you are looking for

  • Please help! MBP 15" 2011 will not boot at all

    Hi, My 15 inch early (May) mbp 2011 will not start up. Here is what I have observed so far: 1) When power button is pushed (without MagSafe attached) hard drive will spin up and about after 3-5 seconds it will turn off (hard drive spins Down, no furt

  • Error 2755, please help!

    Iv just downloaded SDK v1.4.2, and after i tried to install it, i got "internal error 2775. 1624 http://forum.java.sun.com/webapps/download/getfile/1.4.2_01-bo6/windows-i586/java 2 sdk, SE v1.4.2_01.msi" Please help

  • Why is my iTunes gift card not properly activating

    Why won't my iTunes gift card properly activate

  • Error occured when using flash 9 in firefox

    I installed Flash CS3 Professional (trial) for doing assignment. After that, I think flash player also be upgraded to version 9. It's no problem in IE, but when browsing website with using firefox, it keeps pop up windows which ask "Where is the debu

  • Transferring contacts from a backup to outlook

    Alright here is my problem: I backed up my old phone to my computer and now I want to take the contact list from the original backup (I don't have the contact list on my phone anymore) and back it up outlook or my new device. My new device won't let