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>

Similar Messages

  • 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.

  • Question about loading hierarchy

    Hello expert,
           I have some question about hierarchy loading:
             (1) hierarchy DS are all for BW3.X? does it need DTP for this loading ?
             (2) in Process chain,  "DTP process" or "saving hierarchy process"  are all needed in PC ? or just one of them is needed?
    Many Thanks,

    You do not need DTP to load hierarchy.
    In the PC, you need to add the info package and after that attribute change run to load the hierarchy fron hierarchy DS.
    Regards,
    Gaurav

  • Newbie question about precompiling c++ on NT

    I just downloaded Enterprise 8.1.7 for Windows 2000 and am
    trying to precompile some c++ files. Is the precompiler named
    proc like on the unix platforms? During install I selected
    every option to be loaded on but I don't have a proc executable
    anywhere on my system. I want to precompile some embedded sql
    then compile with VC++ 5.0. If anyone could provide some
    assistance and possibly a sample makefile that would be a
    tremendous help. Thanks in advance.

    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>

  • Newbie Question about FM 8 and Acrobat Pro 9

    Hello:
    I have some dcouments that I've written in FM v8.0p277. I print them to PDF so that I can have a copy to include on a CD and I also print some hard copies.
    My newbie question is whether there is a way to create a  PDF for hard copy where I mainitain the colors in photos and figures but that the text that is hyperlinked doesn't appear as blue. I want to keep the links live within the soft copy. Is there something I can change within Frame or with Acrobat?
    TIA,
    Kimberly

    Kimberly,
    How comes the text is blue in the first place? I guess the cross-reference formats use some character format which makes them blue? There are many options:
    Temporarily change the color definition for the color used in the cross-reference format to black.
    Temporarily change the character format to not use that color.
    Temporarily change the cross-reference definition to not used that character format.
    Whichever method you choose, I would create a separate document with the changed format setting and import those format into your book, create the PDF and then import the same format from the official template.
    - Michael

  • Newbie question about saving files

    Hi all,
    A newbie question here, and maybe it is a dumb question, but I can't get my head around this and sofar found no answer in the forums here.
    When I save a file on my macbook, I can only save it to "top" folders.
    What I mean is I try to save a file for instance to documents/worddocs/lyrics just to say something, then I have to save the file first to documents, and the move it to the lyrics folder via finder or move it to :worddocs folder and then move it again to the lyrics folder. Hope you still get my drift here
    Is there a way to just save it to the subfolders without going through all this moving around?
    Thanks in advance for any advice
    Peter

    When you click File>Save As, you will see the Save As window pop up. At the top, you will see a box entitled Save As, which has a space for your to enter the file name. To the right of this box is an arrow pointing down. Click it. The full file hierarchy will be seen. Then you can save directly to the file you want.
    Hope this helps.
    Don

  • Question about Threads/Servlets

    Let's say I have a servlet that opens a socket connection to a server application. On the server end, I would have to make a thread for each connection. But what about the Servlet? do I have to deal with Threads on the servlet side or does the servlet engine takes care of that?

    Unless your servlet implements the SingleThreadModel interface, the servlet container shoud take care of running each request to your servlet in a separate thread.
    Andy Nguyen

  • 2 newbies question about diskgroups

    Hi gurus,
    I have 2 newbies question:
    Im working in a RAC Database (11.2.0.3) on Redhat 5.3 with some disk groups. One of this groups have 6 disks on it with different space (134, 236G, 236G, 185G, 185G and 185G).
    My questions are:
    1) What would be happend when the lower space disk will be full?
    2) At this moment the diskgroups are at 45% so i was thinking to change their spaces to have all with the same space (around 193G each), it would create any problem? i should restart database or can do it with database up?
    Thanks

    if a disk is filled, what would happen? could i resize the disks with same size without stop database and without affecting the data stored within each disc?
    By the word 'disk' I assume you mean LUN . When a LUN in a disk group is filled, ASM will use the remaining LUNs to store the data. You should always use LUNs of uniform size to avoid uneven I/O .
    could i resize the disks with same size without stop database and without affecting the data stored within each disc
    You can get the Unix/Storage team to allocate more LUNs for this Server. Once these LUNs are added , check if the following pre-reqs are met for the LUN which is yet to be added to the disk group
    v$asm_disk.HEADER_STATUS = 'CANDIDATE'
    v$asm_disk.PATH = /dev/rdsk/youLUNname
    v$asm_disk.NAME will be NULL
    Now you can add the LUNs using
    alter diskgroup DATA_DG01 add disk '/dev/rdsk/youLUNname' rebalance power 4 ; wait for rebalance to finish (check status in V$ASM_OPERATION)
    Yes. The above can be done without stopping the DB. It won't affect the stored data either.

  • Two (too much?) newbies questions about KT3 Ultra 2

    Goodmorning all.
    I've bought a KT3 Ultra2 (MS-6380E) motherboard and i've two questions about it.
    First of all I need to buy the optional S-Bracket to use my SPDif sound sistem... where can i buy it in Italy or in Internet?
    In second i've to know the highest processor my MB support becouse i have to upgrade my PC.
    Can U help me?
    Tha a lot and sorry for disturb.
    Hallo.

    Hello,
    question 2, not sure about question 1,
    http://www.msi.com.tw/program/products/mainboard/mbd/pro_mbd_cpu_support_detail.php?UID=341&kind=1
    You may need this BIOS update too.
    http://www.msi.com.tw/program/support/bios/bos/spt_bos_detail.php?UID=341&kind=1

  • Flash newbie questions about slow loading site

    Hi all. I am new to Flash and web-site building in general and I have been learning while doing. Its fun, but frustrating. I really need some help, hope someone out there with Flash experience can give me some advice.
    My problem is this: I built a Flash website, but it is painfully slow to load up (3-5 minutes via cable modem) when I visit the site (via Firefox, etc). Once it does load up, everything is fine with navigation. I'm having a hard time figuring out why its taking so long to load up on the web because, basically, I don't know how to trouble shoot. Hope you guys can help!
    Details: the site is just a portfolio site with pictures and a few motion-things, no complicated animations. The swf file is about 9MB. I do have a flash preloader, but it doesn't show up until after the 3-5 minute "load-up" time. When I do the testing via Flash, its Ok and doesn't show the lag. But once I upload the website files and try to visit my website, the load time problem occurs.
    My thoughts:
    - do I have to purge my Flash file/library of unused images before creating my swf file?
    - Is there a problem with my html code in my index file?
    - because it is a portfolio site, I've got about 90 images on it, each image about 300-400K.  Is this too big, or about right?
    Please help! Sorry for the long email, just desperate for help. Thanks in advance for any advise!!!! Just in case, here is the html code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Acme Company</title>
    <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
    <style type="text/css">
    <!--
    body {
    background-color: #000000;
    -->
    </style>
    <link href="favicon.ico" rel="icon" />
    </head>
    <center>
    <body>
    <script type="text/javascript">
    AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','wid th','800','heigh t','600','title','Acme Company','vspace','100','src','development files/company site_AS2_2008 OCT_final','loop','false','quality','high','plugin spage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgco lor','#000000','scale','exactfit','movie','develop ment files/company site_AS2_2008 OCT_final' ); //end AC code
    </script><noscript><object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="800" height="600" vspace="100" title="Acme Company">
    <param name="movie" value="development files/comapny site_AS2_2008 OCT_final.swf" />
    <param name="quality" value="high" /><param name="BGCOLOR" value="#000000" /><param name="LOOP" value="false" /><param name="SCALE" value="exactfit" />
    <embed src="development files/company site_AS2_2008 OCT_final.swf" width="800" height="600" vspace="100" loop="false" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#000000" scale="exactfit"></embed>
    </object></noscript>

    Yeah I'm with Ned on this one. Dynamically loading your images is the way to go. The fact that you are new to Flash, try this tutorial (http://www.entheosweb.com/Flash/loading_external_images.asp). As you move along in learning Flash, look for tutorials on actionscript arrays and loading images dynamically. Arrays allow you to call each images from a folder outside your fla. That way your site moves right along without much loading time.
    Hope I was of help,
    -Sly

  • Newbie question about Java Studio Creator 2.

    HI all,
    I'm new to JSF and JSC.
    Below are some question which I hope those who has been working on JSF especially those that use JSC to provide me some advice.
    1. Can JSF application developed using JSC be changed or modified using other IDE in the market? Reason being I saw JSC include the position using style in the page. So, I wonder if I use JSC for JSF, will it contraint the future development or not, cos i don't want to be bound by one tool forever.
    2. Is the JSF component (eg. com.sun.rave.web...) provided by SUN are open source?
    3. What is the roadmap for JSC2? Will they continue its development?
    4. JSC2 is free, how about JSC3? Any idea whether it will be free?
    5. Do you think using JSC2 alone is not enough? where to build EJB or web services, we still need to use other tools like NetBeans? What do you use in combination with JSC2? Would like to know your experience.
    6. Can application developed using JSC be deployed to JBOSS?
    7. JSC uses JSF components from SUN (com.sun.rave.web...). So, when we deploy JSF application developed using JSC to tomcat or JBOss, do we need to purchase any license?
    8. I find JSC2 is quite resource hungry, sometimes thing reflect quite slowly. What is your experience using JSC2?
    Thank you.

    Can anyone advise me on my question?
    Thank you.

  • Some questions about Java servlets

    I am having some problems with my Java servlets. Here they are below.
    #1 I have a login jsp page. When user logs in, the MySQL database is queried. If a match, redirect to appropriate page. The problem is I can't seem to remain in the login page if there is no match, I get a blank screen. If there is no match, how can I redirect it back to the login screen? For example, my login screen is login.jsp. Here is my code below.
    while(rs.next())
    if(rs != null)
    String name = rs.getString("USERNAME");
    Cookie getUser = new Cookie("User", name);
    response.addCookie(getUser);
    String sql2 = "INSERT INTO answers (USERNAME) VALUES( '" + name +"')";
    ResultSet rs2 = stmt.executeQuery(sql2);
    response.sendRedirect("profile410.jsp");
    out.println("<p>inside if structure");
    #2 After I go to the first screen after login, I am filling out a questionaire, and everytime I click on a submit button a different servlet comes into play, called InsertRecords.java. Everytime I go from one jsp to another, information gets stored into a database, InsertRecords.java is controlling this. I use the below code.
    String delete = request.getParameter("delete");
    String question = request.getParameter("question");
    String value = request.getParameter("R");
    if (delete.equals("no") && !value.equals(""))
    String sql = "INSERT INTO answers (" + question + ") VALUES (" + value + ")";
    int numRows = stmt.executeUpdate(sql);
    out.println("Record has been inserted");
    String nextPage = request.getParameter("nextPage");
    Cookie[] cookies = request.getCookies();
    if (cookies != null)
    for (int i = 0; i < cookies.length; i++)
    String name = cookies.getName();
    String valuecook = cookies.getValue();
    Cookie getUser = new Cookie(name, valuecook);
    response.addCookie(getUser);
    response.sendRedirect(nextPage);
    the table is answer and the fields are ID, username, and q1, q2 q3, up to q11. the idea is upon login, the username gets stored into the answer table, the field username. I want the values stored in the same row everytime user jumps from one page to another based on his username. Goes to first jsp, q1 gets inserted, next jsp, q2 gets inserted, etc. But they all get inserted diagonally on different rows, not the same one, that is the problem. How can I fix this?
    #2 Based on the above code, say there is 11 jsp pages, remember, this is an online questionaire. When user logs in, he starts at the first jsp page, or question. When for example when the browser gets cut off at question6, when he logs back in, I want him to start at question4, if cut of at question 11, start again upon login at question 8. The reason, so he won't have to start from the beginning. Each question is on seperate jsp's. The way I see this happening is creating a session upon login and keeping that session. And grab 4th question when he logs back in, but I am not sure about how to go about it.
    Can someone help me please?

    Q1:
    Use the update command and not insert.
    Q2:
    Won't work. The user may log back in after the session has expired or from a different location. On log in look for a record for that user and what questions have been answered so far.

  • (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 :-)

  • Question about Load balancing with IISPROXY

              Hi,
              We are running WLS 5.1.0 SP5 on NT 4.0 SP6. We are not using clustering.
              We are able to round robin between multiple instances of the WLS successfully.
              Question: If one of the instances of WLS goes down, is there any way to configure
              the plugin to take it out of the loop automatically (without using clustering)?
              Thanks,
              Anil.
              

    This is not the syntax. Syntax is just this:
              MaxSkips=something.
              eg: MaxSkips=25
              The doc says:
              5:10:1000 for min:default:max
              By which we mean that default value is 10, max is 1000 and min is 5. I guess the
              docs are confusing about the syntax here. We will correct them.
              --Vinod.
              Anil Kommareddi wrote:
              > Vinod,
              > I could not find any documentation on the MaxSkips parameter except in the Service Pack
              > docs. The syntax is MaxSkips=min:default:max.
              >
              > how do the min and max parameters work?
              >
              > Vinod Mehra wrote:
              >
              > > Even if the servers in the WebLogicCluster list are non clustered you WILL be
              > > able to do load balancing. But the problem is if the servers go down the plugin
              > > will not remove them. But it not that bad. If an connection attempt fails the
              > > server is marked as bad and will be skipped for the next MaxSkips (default=10)
              > > cycles of load balancing. MaxSkips parameter is configurable for IISProxy
              > > (SP4 onwards, I think).
              > >
              > > -Vinod.
              > >
              > > Prasad Peddada wrote:
              > >
              > > > I believe there won't be any load balancing unless you use servers in a cluster. As
              > > > an alternative you can use hardware load balancers directly in a situation like this.
              > > >
              > > > Anil Kommareddi wrote:
              > > >
              > > > > Hi,
              > > > >
              > > > > We are running WLS 5.1.0 SP5 on NT 4.0 SP6. We are not using clustering.
              > > > > We are able to round robin between multiple instances of the WLS successfully.
              > > > >
              > > > > Question: If one of the instances of WLS goes down, is there any way to configure
              > > > > the plugin to take it out of the loop automatically (without using clustering)?
              > > > >
              > > > > Thanks,
              > > > > Anil.
              > > >
              > > > --
              > > > Cheers
              > > >
              > > > - Prasad
              

  • Newbie question about Premiere Elements Organizer

    This is a pre-newbie – let’s say “virgin” question. If there is an answer already posted elsewhere, please send me a link.
    I’m about to install Premiere Elements 9 to do some clip editing and animation from still images.  This would be my first attempt to edit clip or do some animation from still images, besides using Windows Media Maker with my HS students. However, I have been a pretty serious photographer for 20+ years with 1,000’s of images which I now work on in PS CS5 Extended and Lightroom 3. I use Adobe Bridge and LR library to catalogue and organize my images. I’d like to continue to use AB / LR Library to organize my new clips and projects. From reading Bill’s posts, it seems I can use Adobe Bridge, copy my original file, resize in Photoshop, and save in a new folder to use for a Premiere project. This would seem to be most intuitive way for me to work. I already have keywords, metadata, actions in PS… etc. But I think Bill is using Premiere Pro, while I’ll be installing Premiere Elements, which comes bundled with Elements Organizer. Do I need to install or use Elements Organizer? What are the advantages/disadvantages or EO?  I guess I’m a little worried about installing the programs and having EO automatically acquire images using presets/defaults that I don’t want to use as well as issues with subfolders, etc. I'm running Windows 7.
    Thanks
    FYI- this is a great animation project
    http://www.thejohnnycashproject.com/#/explore/TopRated

    ziggycat4 wrote:
    I guess I’m a little worried about installing the programs and having EO automatically acquire images using presets/defaults that I don’t want to use as well as issues with subfolders,
    EO doesn't do much with the files themselves, just maintains links to the sources.
    For folders you are best to use the folder view in EO to move them as it doesn't keep track of folder locations when changed in Windows Explorer. From the File options in Bridge I think that is pretty much the same.
    ziggycat4 wrote:
    I would like to get as much input as possible on the advantages/disadvantages of using EO vs say Adobe Bride from others who use Elements Organizer.
    Any insights would be appreciated.
    Can anyone who has used both EO and AB comment on how EO handles missing (hidden) files, syncing issues, computer hanging up or crashing....etc?
    I've only messed around a little with Bridge. But to me it seems lightening fast by comparison to EO. The features Albums and Tags in EO seem much the same as Collections and Keywords in Bridge.
    EO has Face Recognition abilities - getting more sophisticated in each version. I've not seen this feature in Bridge.
    By default EO allows you to open a file in any of:
    Photoshop
    Photoshop Elements
    Premiere Elements
    A single used-defined application (I have mine set to ColorPilot).
    Bridge only seems to link to Photoshop.
    Missing files can be located manually or by allowing EO to search for them.
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children

Maybe you are looking for

  • Safari Crashes after opening - with report

    I have read other posts that said to remove the history file, but this did not work for me... Crash Report Date/Time: 2008-09-03 09:50:10.179 -0400 OS Version: 10.4.11 (Build 8S2167) Report Version: 4 Command: Safari Path: /Applications/Safari.app/Co

  • Working Area for Internal Table

    Hi,   i know that process of internal table if it is with headerline but i don't know how the data pass to our internal table if it is with out header line plzz give me the example code for that. Thanks in advance

  • Buying tv shows off of itunes

    does anyone know if itunes music store will be selling tv shows in Canada anytime in the near future?

  • Mapping issue - nQSError: 15018

    hi.. I have creataed a new business model which contains 3 fact table(f1, f2, f3) and 3 dimension tables(d1, d2, d3).. Initially in the physical layer the fact table f3 was absent and thats why i have created that and make a primary key and mapped th

  • Filevault 2 encryption and USB flash drives in Lion 10.7.1

    I have my harddrive on my MacBook Air encrypted with File Vault 2 under Lion 10.7.1  Seems to work fine until I try and backup using time machine. Its very very very slow. - its saying it will take days to back up 90GB  to a 256GB USB memory stick. I