Newbie Question - Accessing Servlet Class file

im trying to run my servlet class file but am not able to do so. I've compiled my servlet and the class file generated is under build...web-inf/classes as it should be. Now how i do access this through the browser , isnt it just not localhost:29080/MyWebApp/HelloServlet. Thanks
-newbie

Hi There,
Are you using Java Studio Creator to develop your application? If so this tutorial will help you get started.
http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/jscintro.html
Please also visit the tutorials page at
http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/index.jsp
Thanks
K

Similar Messages

  • (newbie) Question about replacing .class files and web.xml file

    I'm new to servlets and I have two quick questions...
    Do I absolutely need a web.xml file to define all my servlets, or can I simply place .class files into the WEB-INF directory and expect them to run?
    If my application server (for example Tomcat) is running and I replace a servlet .class file, do I need to restart the server for the new .class file to take effect?
    ...or are both of these questions specific to the application server I'm using?

    Hi,
    From an article I read:
    With Tomcat 3.x, by default servlet container was set up to allow invoking a servet through a common mapping under the /servlet/ directory.
    A servlet could be accessed by simply using an url like this one:
    http://[domain]:[port]/[context]/servlet/[servlet full qualified name].
    The mapping was set inside the web application descriptor (web.xml), located under $TOMCAT_HOME/conf.
    With Tomcat 4.x the Jakarta developers have decided to stop allowing this by default. The <servlet-mapping> tag that sets this mapping up, has been commented inside the default web application descriptor (web.xml), located under $CATALINA_HOME/conf:
    <!-- The mapping for the invoker servlet -->
    <!--
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
    -->
    A developer can simply map all the servlet inside the web application descriptor of its own web application (that is highly suggested), or simply uncomment that mapping (that is highly discouraged).
    It is important to notice that the /servlet/ isn't part of Servlet 2.3 specifications so there are no guarantee that the container will support that. So, if the developer decides to uncomment that mapping, the application will loose portabiliy.
    And declangallagher, I will use caution in future :-)

  • How to access a class file outside the package?

    created a two java files Counter.java and TestCounter.java as shown below:
    public class Counter
         public void print()
              System.out.println("counter");
    package foo;
    public class TestCounter
         public static void main(String args[])
              Counter c = new Counter();
              c.print();
    Both these files are stored under "D:\Test". I first compiled Counter.java and got Counter.class which resides in folder "D:\Test"
    when i compile TestCounter.java i got the following error message:
    D:\Test>javac -classpath "d:\Test" -d "d:\Test" TestCounter.java
    TestCounter.java:6: cannot find symbol
    symbol : class Counter
    location: class foo.TestCounter
    Counter c = new Counter();
    ^
    TestCounter.java:6: cannot find symbol
    symbol : class Counter
    location: class foo.TestCounter
    Counter c = new Counter();
    ^
    2 errors
    what could be the problem. Is it possible to access a class file outside the package?

    ya that's fine..if we have two java files where both resides in the same package works fine or two java files which donot have a package statement also works fine. But my doubt is, i have a Counter.class which does not reside in a package and i have a TestCounter.class which resides in a package "foo", in such a scenario, how do i tell to the compiler that "Counter.class resides in such a path, please look at that and give me TestCounter.class". i cannot use import statement to import Counter.class in TestCounter.java because i donot have a package for Counter.java.

  • Problem for retriveing servlet class file (error in DD) I think so

    hi to all ,
    my deployment descriptor is here ....
    I tried to access servlet ... I got the response is like that
    The requested Resource is not available
    why its happening ?
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!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>
    <welcome-file-list>
         <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <listener>
         <listener-class>CallMonitor.MyListener</listener-class>
    </listener>
    <servlet>
         <servlet-name>LoginAction</servlet-name>
         <servlet-class>LoginAction</servlet-class>
    </servlet>
    <servlet>
         <servlet-name>InsertData</servlet-name>
         <servlet-class>InsertData</servelt-class>
    </servlet>
    <servlet-mapping>
         <servlet-name>LoginAction</servlet-name>
         <url-pattern>/LoginAction</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
         <servlet-name>InsertData</servlet-name>
         <url-pattern>/InsertData</url-pattern>
    </servlet-mapping>
    <context-param>
         <param-name>jdbcurl</param-name>
         <param-value>jdbc:mysql://localhost:3306/test</param-value>
    </context-param>
    </web-app>But i remove the code from it , i can access LoginAction Servlet..
    <servlet>
         <servlet-name>InsertData</servlet-name>
         <servlet-class>InsertData</servelt-class>
    </servlet>
    <servlet-mapping>
         <servlet-name>InsertData</servlet-name>
         <url-pattern>/InsertData</url-pattern>
    </servlet-mapping>
    In Tomcat manager i found the applicaton is not running.
    i started the application using start command...
    But i got error message
    FAIL - Application at context path /25.7 could not be started
    Message was edited by:
    kannankalli

    <servlet-class>InsertData</servelt-class>Closing element for <servlet-class> is wrong.
    Before posting for any help check following stuff
    - Whether deployment descriptor is well-formed
    - Whether it is valid i.e. all elements are properly placed

  • Where to store the servlet class files ?

    If, I store the class files for servlets under WEB-INF/classes folder,
              i get file not found exception while using WL 6.1 sp2. But, if i store
              the class file under DefaultWebApp folder, it works fine.
              Any help about where to store the class files for servlets would be
              great help.
              Thanks.
              hiren
              

    Copy Servlet in DefaultWebApp/Web-Inf/classes directory.
              Configure Servlet in web.xml deployment descriptor.
              <servlet>
              <servlet-name></servlet-name>
              <servlet-class></servlet-class>
              </servlet>
              <servlet>
              <servlet-name></servlet-name>
              <servlet-class></servlet-class>
              </servlet>
              <servlet-mapping>
              <servlet-name></servlet-name>
              <url-pattern></url-pattern>
              </servlet-mapping>
              hiren dossani wrote:
              > If, I store the class files for servlets under WEB-INF/classes folder,
              > i get file not found exception while using WL 6.1 sp2. But, if i store
              > the class file under DefaultWebApp folder, it works fine.
              > Any help about where to store the class files for servlets would be
              > great help.
              >
              > Thanks.
              >
              > --
              > hiren
              

  • Question about multiple class files

    I just started learning JAVA a couple of days ago and the first program I wrote had two classes in one file. here is the program :
    class fib_num {
    public int value;
    public boolean is_even;
    class Fibonacci {
    /** Print the Fibonacci sequence for values < MAX and mark even numbers with an asterick */
    private static final int MAX = 50;
    private static final String Title = "The Fibonacci sequence for values less than " + MAX + ":";
    private static fib_num[] fib = new fib_num[MAX];//This is actually an array of object
    //references to objects of the fib_num class
    public static void main(String[] args) {
    System.out.println(Title);
    //We must initialize each element of the array also !!!!
    for (int i = 0; i < fib.length; i += 1) {
    fib = new fib_num();
    int lo = 1, hi = 1;
    fib[0].value = lo;
    fib[0].is_even = false;
    fib[1].value = hi;
    fib[1].is_even = false;
    for (int i = 2; i < fib.length; i += 1) {
    //create the next Fibonacci number and then save the previous Fibonacci number
    hi = lo + hi;
    lo = hi - lo;
    fib.value = hi;
    //now indicate if the Fibonacci number is even/odd
    if (fib.value % 2 == 0) {
    fib.is_even = true;
    }else {
    fib.is_even = false;
    print (fib);
    //This method prints an array of Fibonacci numbers
    public static void print(fib_num[] array) {
    if (array == null || array.length == 0)
    throw new IllegalArgumentException();
    String mark;
    for (int i = 0; array.value < MAX; i += 1) {
    if (array.is_even) {
    mark = "*";
    }else {
    mark = "";
    System.out.println((i + 1) + ": " + array.value + mark);
    I ran the program and everything went fine. But today I started to write another program with two classes. However the file will not compile and I get an error about interfacing or something. here is the program:
    Note: it's not nearly complete.
    class enumerate {
    //print out all permutations of a list of integers
    public static final int MAX = 4;
    public static int[] initialize(int[] nums) {
    for (int i = 0; i < nums.length; i++) {
    nums = i + 1;
    return nums;
    public static void print(int[] nums) {
    for (int i = 0; i < nums.length; i++) {
    System.out.print(nums);
    System.out.println("");
    public static void swap (int[] nums, int i, int j) {
    int temp = nums;
    nums = nums[j];
    nums[j] = temp;
    public static void main (String[] args) {
    int[] list = new int[MAX];
    list = initialize(list);
    PermutationGenerator x = new PermutationGenerator(5);
    // Systematically generate permutations.
    import java.math.BigInteger;
    public class PermutationGenerator {
    private int[] a;
    private BigInteger numLeft;
    private BigInteger total;
    // Constructor. WARNING: Don't make n too large.
    // Recall that the number of permutations is n!
    // which can be very large, even when n is as small as 20 --
    // 20! = 2,432,902,008,176,640,000 and
    // 21! is too big to fit into a Java long, which is
    // why we use BigInteger instead.
    public PermutationGenerator (int n) {
    if (n < 1) {
    throw new IllegalArgumentException ("Min 1");
    a = new int[n];
    total = getFactorial (n);
    reset ();
    // Reset
    public void reset () {
    for (int i = 0; i < a.length; i++) {
    a = i;
    numLeft = new BigInteger (total.toString ());
    // Return number of permutations not yet generated
    public BigInteger getNumLeft () {
    return numLeft;
    // Return total number of permutations
    public BigInteger getTotal () {
    return total;
    // Are there more permutations?
    public boolean hasMore () {
    return numLeft.compareTo (BigInteger.ZERO) == 1;
    // Compute factorial
    private static BigInteger getFactorial (int n) {
    BigInteger fact = BigInteger.ONE;
    for (int i = n; i > 1; i--) {
    fact = fact.multiply (new BigInteger (Integer.toString (i)));
    return fact;
    // Generate next permutation (algorithm from Rosen p. 284)
    public int[] getNext () {
    if (numLeft.equals (total)) {
    numLeft = numLeft.subtract (BigInteger.ONE);
    return a;
    int temp;
    // Find largest index j with a[j] < a[j+1]
    int j = a.length - 2;
    while (a[j] > a[j+1]) {
    j--;
    // Find index k such that a[k] is smallest integer
    // greater than a[j] to the right of a[j]
    int k = a.length - 1;
    while (a[j] > a[k]) {
    k--;
    // Interchange a[j] and a[k]
    temp = a[k];
    a[k] = a[j];
    a[j] = temp;
    // Put tail end of permutation after jth position in increasing order
    int r = a.length - 1;
    int s = j + 1;
    while (r > s) {
    temp = a[s];
    a[s] = a[r];
    a[r] = temp;
    r--;
    s++;
    numLeft = numLeft.subtract (BigInteger.ONE);
    return a;
    I thought the error had somethin to do with only having one class per .java file since the compiler creates a .class file. But how come my first program had two classes and it was OK. Is it b/c the second class was merely a collection of fields, almost like a simple struct in C?
    Any help would be appreciated. Thanks

    Move the import java.math.BigInteger line to the start of the file.
    Use the "[ code ] [ /code ]" tags around your code when you post, it makes reading it a lot easier.

  • Relative path to file in servlet class file

    Hello,
    I have several classes running as a Tomcat Servlet on my server. However, I have one class that I would like to access a file on the server.
    The problem is, what path do I use? I want to use a relative path as the servlet might be moved and I don't want to recompile each time the servlet is moved. For instance, I placed the file in the servlet directory under webapps in the same level with the WEB-INF directory. However, using "../../text.txt" does not seem to access it.
    What path should I use?
    Thanks in advance.
    Chris

    This is what I have done:
         String FS = System.getProperty("file.separator");
         String ctx = getServletContext( ).getRealPath( "" ) + FS;
         URL url = new URL("file", "", ctx +   "somefile.txt");
         //Create a BufferedReader for reading the inputstream.
         BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));This gets you back to the "root", or one level above WEB-INF. Add the folder name where the file is located. As in      URL url = new URL("file", "", ctx +   "theFolder/somefile.txt");HTH,
    WalkGood

  • Mapping logical names to a servlet class file

    Hello sir,
    I am a student, new to jsp servlets and was going through the book Head first jsp servlets , where it told that in a html if there is a form saying <form method="post" action="SelectBeer.do" then the browser prepends "/beer-v1" and makes the final url something like "/beer-v1/SelectBeer.do" because that's where the client request is coming from. i.e. the "SelectBeer.do" in the html is relative to the url of the page it is on.
    Now I want to ask that say if the file structure in tomcat is something like
    WEB-CONTENT
    |____________________________JSP
    |..................................................|________________________PAGE1.JSP
    |..................................................|________________________PAGE2.JSP
    |
    |____________________________HTML
    |..................................................|________________________PAGE3.HTML
    |..................................................|________________________PAGE4.HTML
    |
    |____________________________CLASSES
    |.................................................|________________________SERVLET1.CLASS
    And if a html form is on page "PAGE1.JSP" AND WANTS TO GO TO "PAGE3.JSP" or to "SERVLET1.CLASS"Then what relative url should be given in form action method.
    Thanks in advance

    You can use '..' to go 'up' a level in the structure.
    So if you are currently on page http://localhost:8080/myApp/JSP/PAGE1.JSP
    page2 --> page2.jsp
    page3 --> ../html/page3.html or /myApp/html/page3.html
    servlets are different because they are not directly accessed by their location on disk, but rather by url mappings in the web.xml file.
    One other trick to watch out for in this is that the name of the web application - the 'context', also forms part of the url (in my example I called it myApp).
    You need to include the context path in absolute urls from the client (for loading scripts/images etc)
    You do NOT use the context path in absolute urls from the server - ie those used with the RequestDispatcher, because the RequestDispatcher treats the context as the root, while your web browser has a different idea.
    So you would use <jsp:forward page="/jsp/page1.jsp"/> to forward to a page, but link for a link to it from another page.
    cheers,
    evnafets

  • Newbie question on managing catalog files & external drives

    I'm new to Lightroom and just downloaded a trial version of LR4 earlier this week.  I'm an amatuer photographer (and I really mean amatuer ) ... and serve as a volunteer for a local summer baseball team (college players).  I've taken - on average - 5,000 photos per summer for each of the last 5 years. In addition to posting the photos of each game to my Phanfare.com site (where players and families can download them), I create a keepsake DVD with video clips and a slideshow for the players and coaches at the end of the season.  If I decide to become a LR4 user, I would be organizing those photos from the past...as well as on a game-by-game basis this coming summer and into the future.  In addition to backing up all of my photos to DVD and Phanfare.com, I have a designaed external hard drive for these photos.  On the external drive, I have a different folder for each year and subfolders for each game.  In the past, I've kept the current year photos on my laptop and back them up to the other locations as the season progressess. 
    As I map out my plans, I'm trying to figure out the best way to manage the past years photos, current year photos and the related catalog file(s).  I won't always have the large external hard drive with me....and I don't have enough room on my laptop for all years.  There are times I need to search for photos across multiple years; there are times only in the current year...although I have no problem restricting myself to using the large "master" external hard drive for those multiple year searches.  I do have a portable 160 GB hard drive at my disposal that I can use and take with my laptop at all times if needed.  
    Would appreciate any advice on how best to set up the catalog files so that I can manage current year and past year photos...meet my mobility requirements for the current year...as well as the master external hard drive.
    Thanks in advance for your help.  (Hopefully my explanation and question makes sense)
    Ralph
    (PC / Windows 7)

    Advice #1: use one catalog -- don't even think about multiple catalogs; multiple catalogs will not help, this will only hinder you in your work. Inside of Lightroom, you can easily organize different years, different teams, different players, different sports, and anything else you want to organize.
    With regards to travel, you can export portions of your catalog to whatever HD you want to take with you.

  • Newbie question: integrating SWF, movie files

    Hi all!
    Thanks in advance for your help--I'm trying to use Flash to
    integrate several files into a slick screencast. Basically, I need
    to use Flash to play a movie file, then play a SWF file, then
    another movie file and be done. I was hoping to also put in some
    text and animation (PowerPoint-like, not too intense) in between
    those things, but can jettison that if that's difficult.
    I know the import command does wonders with one video, but
    I'm trying to use multiple types of files including SWFs, which is
    throwing me off a bit. I realize I'm being incompetent here, but if
    anyone has any suggestions, I'd really appreciate it. And this goes
    without saying, but I don't mind coding at all.

    I strongly recommend you to use Compressor. It is easy to use and there a lot  of presets.

  • Servlet class file size limit

    hi,
    Does any one have any idea abt the max size a compiled java class can have?? My problem is my jsp is too big bcause of which my tomcat is crashing.. does anyone have any solution or work around for this?? If so pls help.

    Seen this once before. Not sure but the limitation might be on the size of a paricular method vs. the overall class size. Try putting large strings in final static Strings in the class block at the top of the .jsp so that they end up as member variables. Or split up the output into static functions. If that doesn't work split up the .jsp into more than one .jsp, and use jsp include.

  • Newbie Question - Accessing Email Over Network

    OK so I purchased a laptop and set up a wireless network in my home. Everything seems to be working fine except I can't figure out how to see my incoming emails from the laptop. I get the mobileme messages on the laptop but not the messages that are coming in from my email provider. I could go into share screen mode and see emails on the IMAC that way. What am I doing wrong??

    Do you have your email account on MobileMe or with another ISP? If the latter then you need to configure an account for your regular email provider, not MobileMe.

  • Newbie question about loading servlets on tomcat

    I have what is probably a very basic question about loading simple servlets on to tomcat to test its installation. I have followed instructions from numerous tutorials to the letter but still I can't get it to work.
    I have installed tomcat on win2k in c:\tomcat. I set up the jdk, environment vars (JAVA_HOME, CATALINA_HOME, TOMCAT_HOME) which all point at the correct dirs. I can compile a servlet without errors. I can also place a test jsp and html file into the root directory and they both work fine.
    However, now I am trying a test servlet and no matter what I do it gives me a 404. I have a servlet class file called "HelloServlet.class" which I placed into the %install_dir%\webapps\ROOT\WEB-INF\classes directory. I try to reference it using this url:
    http://localhost/servlet/HelloServlet
    Tomcat is configured to use port 80 and has been restarted after adding the servlet class file. Does anyone have a clue why this is not working for me?
    Many thanks
    Marc

    You have to add in the web.xml file that it is in the WEB-INF dir, the information about your servlet. An example:
    <web-app>
    <servlet>
    <servlet-name>HelloServlet</servlet-name>
    <servlet-class>HelloServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloServlet</servlet-name>
    <url-pattern>/HelloServlet</url-pattern>
    </servlet-mapping>
    </web-app>

  • How to convert java class file version without decompiling

    Hi,
    Oracle R12.1.3 i am having illegal access error while try to access the class file version Java 1.3 uses major version 47,So how to convert the class file version without using decompiling.
    Current java version is 1.6.0_07
    Is there any tool or API for converting class file version?
    Thanks,
    Selvapandian T

    Beside this I wonder where you get your error from since AFAIK 12c comes with java 1.6.
    Well wonder no more!
    OP isn't using Oracle 12c database.
    They are using Oracle R12.1.3 - which is the E- Business Suite.

  • 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

Maybe you are looking for

  • Read categories of CRM order

    Hi all! My task is to read categories of crm order (i.e. fields category_1 ... category_4 at the order header level). May be someone could tell me some functionality to get this data? I'll be appreciated. Best regards, Alexander Kirillov

  • My iPod camera is very blurry after dropping it. What do I do???

    I dropped my iPod touch 5 and the camera became very blurry , and after a few seconds it freezes. What should I do??? iPod touch 5th gen, iOS 8.3, 32GB

  • Displaying Picture in a Java APPLICATION please help!!

    I have been trying to write a method that Displays a .jpg file when called. However I have not gotten far, every book I have tell you how to display pictures in an applet but not an application. I did find some code that is supposed to be for an appl

  • Open Hub Destination - csv files

    Hi all, I nedd to send information through Open Hub Destination from a cube to a File in a server. But the Open Hub Destination is originating 2 csv files instead of 1: one of the files has just the name of the fields that will be in the columns and

  • Puppet Tool RT Preview Issue

    Since CC 2014, I'm having odd issues with the puppet tool. It works as expected until I get to RAM preview it. The preview happens, but playback only happens at around 37fps (is a 60fps comp) and the distort effect does nothing, YET if I scrub the ti