Can i run a servlet without a web.xml file for servlet mapping?

Hello everyone.
The code i want to run compiles and everythink looks ok.
It produces the .class file.
I run Tomcat 4.1 and i build my Web site with Dreamweaver.
I have a form in a page and i want to send the data upon form completion to a database i already have build with MySql.
The database is up and running and the server is set-up ok.
I have changed the port in Tomcat to run on port 80.
The directory i have my site is
Tomcat41\webapps\ROOT\se
and the directory where i keep the servlet class is
Tomcat41\webapps\ROOT\se\WEB-INF\servlet
I have a web.xml file to map the servlet and placed it in
Tomcat41\webapps\ROOT\se\WEB-INF
In the Form action i write action:"/servlets/Classes/GroupRegistration"
and I RECEIVE AN 404 ERROR FROM APACHE.
Somethink is wrong .
The following is the code from the GroupRegistration.java file
and follws the web.xml file.
Please Help.
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class GroupRegistration extends HttpServlet
Connection con;
public void doPost (HttpServletRequest req, HttpServletResponse res)
                         throws ServletException, java.io.IOException
     handleForm(req, res);
public void init() throws ServletException {
     try{
     /* Loading the driver for the database */
     Class.forName("com.mysql.jdbc.Driver");
     Connection Con = DriverManager.getConnection("jdbc:mysql://localhost/se?user=luser&password=");
     catch (ClassNotFoundException e) {
     throw new UnavailableException("Couldn't load JdbcOdbcDriver");
     catch (SQLException e) {
     throw new UnavailableException("Couldn't get db connection");
     private void handleForm(HttpServletRequest req, HttpServletResponse res)
     throws ServletException {
     //ServletOutputStream out = res.OutputStream();
     //res.setContentType("text/html");
     //Extract the form Data Here
     String group = req.getParameter("GroupNo");
     String Name1 = req.getParameter("Name1");
     String LoginID1 = req.getParameter("LoginID1");
     String Name2 = req.getParameter("Name2");
     String LoginID2 = req.getParameter("LoginID2");
     String Name3 = req.getParameter("Name3");
     String LoginID3 = req.getParameter("LoginID3");
     String Name4 = req.getParameter("Name4");
     String LoginID4 = req.getParameter("LoginID4");
     String URL = req.getParameter("URL");
     String Title2 = req.getParameter("Title2");
     String date = req.getParameter("date");
     String INSERT = "INSERT INTO registration (groupno, name1, loginid1, name2, loginid2, name3, loginid3, name4, loginid4, url, topic, date) VALUES (" + group + "," + Name1 + "," + LoginID2 + "," + Name2 + "," + LoginID2 + "," + Name3 + "," + LoginID3 + "," + Name4 + "," + LoginID4 + "," + URL + "," + Title2 + "," + date + ")";
     PreparedStatement pstmt = null;
     try{
     pstmt = con.prepareStatement(INSERT);
     pstmt.executeUpdate();
     catch (SQLException e) {
     throw new ServletException(e);
     finally {
     try {
     if (pstmt != null)pstmt.close();
     catch (SQLException ignored){
The web.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com.xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<servlet>
<servlet-name>GroupRegistration</servlet-name>
<servlet-class>GroupRegistration</servlet-class>
</servlet>
<servlet-maping>
<servlet-name>GroupRegistration</servlet-name>
<url-pattern>/myGroupRegistration</url-patern>
</servlet-mapping>
</web-app>
I apreciate your time.
Thanks for any help.

and the directory where i keep the servlet class is
Tomcat41\webapps\ROOT\se\WEB-INF\servletOthers have pointed out that "servlet" should be "classes", but there is another mistake that hasn't been spotted. If you want your servlet to appear in the root context, you should use:
Tomcat41\webapps\ROOT\WEB-INF\classes
If you want your servlet to appear under the /se context, then you should use:
Tomcat41\webapps\se\WEB-INF\classes
and also, in the latter case, your form action should be /se/myGroupRegistration.

Similar Messages

  • How to run java servlet without using Web.xml?

    How to run servlet without using Web.xml? From a book, I know that web.xml descriptor is optional, but the book doesn't tell us how to run java servelet without web.xm descriptor. So how to do that? Thanks a lot.

    How to run servlet without using Web.xml?But Tomcat now uses a web.xml for its global server-wide configuration.
    If you'd like to invoke a servlet with:
    http://host/servlet/ServletName
    you have to enable the invoker servlet.
    [from an HTML]
      <FORM METHOD="POST" ACTION="/servlet/HGrepSearchSJ">
    [from resin.conf of Resin Web Server 2.1.12]
      <!--
         - The "invoker" servlet invokes servlet classes from the URL.
         - /examples/basic/servlet/HelloServlet will start the HelloServlet
         - class.  In general, the invoker should only be used
         - for development, not on a deployment server, because it might
         - leave open security holes.
        -->
      <servlet-mapping url-pattern='/servlet/*' servlet-name='invoker'/>
    [from TOMCAT5.0.19/conf/web.xml, a global server-wide web.xml file]
      <!-- The "invoker" servlet, which executes anonymous servlet classes      -->
      <!-- that have not been defined in a web.xml file.  Traditionally, this   -->
      <!-- servlet is mapped to URL pattern "/servlet/*", but you can map it    -->
      <!-- to other patterns as well.  The extra path info portion of such a    -->
      <!-- request must be the fully qualified class name of a Java class that  -->
      <!-- implements Servlet (or extends HttpServlet), or the servlet name     -->
      <!-- of an existing servlet definition.     This servlet supports the     -->
      <!-- following initialization parameters (default values are in square    -->
      <!-- brackets):                                                           -->
      <!--                                                                      -->
      <!--   debug               Debugging detail level for messages logged     -->
      <!--                       by this servlet.  [0]                          -->
        <servlet>
            <servlet-name>invoker</servlet-name>
            <servlet-class>
              org.apache.catalina.servlets.InvokerServlet
            </servlet-class>
            <init-param>
                <param-name>debug</param-name>
                <param-value>0</param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
        </servlet>
    ---comment out below----------------------------------------------------------
        <!-- The mapping for the invoker servlet -->
    <!--
        <servlet-mapping>
            <servlet-name>invoker</servlet-name>
            <url-pattern>/servlet/*</url-pattern>
        </servlet-mapping>
    -->

  • Automate creation of web.xml file for tomcat 4.1.29

    hi , this is with ref to Tomcat 4.1.29, if i am correct, each Servlet in the application has to be mentioned in the web.xml file for the Tomcat to know about it. Is there any way to automate the creation of web.xml file , depending on the contents of the Servlet folder of the application. Any way to escape from writing each Servlet name in web.xml file.
    rc

    Hello,
    Maybe you should check if you can use Ant tool to do
    that. I am not sure if it can help u.
    Zeph.
    http://ant.apache.org/
    It will, specially if used in conjunction with XDoclets :
    http://xdoclet.sourceforge.net/
    XDoclet has Ant tasks to generate web.xml files.

  • XML Question for web.xml file for LiteWebServer

    Hi,
    I have no clue of wut tags are required in the web.xml file.
    Currently the following code is in my web.xml file and i am trying to run servlets that are located under web-inf/*.class
    Pls tell me wuts wrong....
    Do i need those mime-mapping tags, session and welcome tags.......... ?
    Right now i just want those 2 servlets to work
    And wut is this encoding ="UTF-8" in the first line of the xml file. Wut does that do... ? ARe there any others
    Any help would b greatly appreciated
    Thanks
    <?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 id="WebApp_1">
    <display-name>PDMPortal</display-name>
    <session-config id="SessionConfig_1">
    <session-timeout>60</session-timeout>
    </session-config>
    <mime-mapping id="MimeMapping_1">
    <extension>htc</extension>
    <mime-type>text/x-component</mime-type>
    </mime-mapping>
    <welcome-file-list id="WelcomeFileList_1">
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
    <servlet-name>HelloWorld</servlet-name>
    <servlet-class>HelloWorld</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>HelloWorldExample</servlet-name>
    <servlet-class>HelloWorldExample</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>HelloWorld</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>HelloWorldExample</servlet-name>
    <url-pattern>HelloWorldExample</url-pattern>
    </servlet-mapping>
    </web-app>

    Try putting your servlets in the WEB-INF\classes directory.

  • Virtual-mapping in jrun-web.xml file for CFIDE is not working

    I have put virtual-mapping for my web root into jrun-web.xml
    file. It looks like this:
    <virtual-mapping>
    <resource-path>/*</resource-path>
    <system-path>E:/WebSites/mywebroot</system-path>
    </virtual-mapping>
    So I need give virtual-mapping for my CFIDE too. It looks
    like this:
    <virtual-mapping>
    <resource-path>/CFIDE/*</resource-path>
    <system-path>E:/Apps/JRun4/servers/myserver/cfusion-ear/cfusion-war/CFIDE</system-path>
    </virtual-mapping>
    It is now working for me. When I use following url:
    http://localhost:8002/CFIDE/administrator
    I am getting "HTTP 404 - File not found". I have set it for
    other servers they are working on same server. What I did wrong
    this time?
    Thanks ahead.
    Mikenj

    Hi John,
    i did some some changes in Account dimension in my Planning Dev server. When i was migrating it to QA using LCM in shared services it is howing this error: Import failed for the following reason - Error parsing the deployment xml.
    First i define migration in Dev for export and the migration was successful.Then i went into QA shared services and started migration, i got this error for importing.
    Could you help me out on this?
    Regards,
    Shilpa

  • Do I must put ALL my servlets inside the web.xml file?

    Hello everybody,
    I am trying to migrate from Webshere to TOMCAT a project with severals packets, one of those have 15 servlets and some classes.
    Is there any way to use the servlets without have to declare each one inside the web.xlm file ?
    Thanks in advance.

    All servlet definitions go into web.xml, though not the actual servlets themselves :) . Say if you wanted servlet A to have a different mapping you would define the mapping in web.xml to something other than the standard one.

  • Servlet parameters in web.xml file

    Hi Guys
    What is ctx:dynamo: in web.xml why we have to use this one in servlet parameters
    Please give me a clear picture on this
    <init-param>
        <param-name>jumpServlet</param-name>
        <param-value>
          ctx:dynamo:/atg/dynamo/servlet/dafpipeline/JumpServlet
        </param-value>
      </init-param>

    Hi Guys
    What is ctx:dynamo: in web.xml why we have to use this one in servlet parameters
    Please give me a clear picture on this
    <init-param>
        <param-name>jumpServlet</param-name>
        <param-value>
          ctx:dynamo:/atg/dynamo/servlet/dafpipeline/JumpServlet
        </param-value>
      </init-param>

  • Where to save web.xml file in apache jserv with servlet 2.0

    hi,
    we are using apache jserv which included servlet 2.0 we are able to run .class files and
    jsp files,but we are using web.xml file for connection pooling which we were used in tomcat
    but we are unable to find web-inf folder in apache/jserv to save the file.
    please help me out in this problem,
    please guide us is there any other method of connection pooling apache jserv,we are using backend
    as oracle9i
    i will be greatfull to u in this regards
    laiq

    Hi,
    Just create WEB-INF folder and copy the web.xml.
    good luck !
    ...san :-)

  • Help on web.xml file, what if the parameters contains key words ?

    Hi:
    I am just wondering what should I do if I want to include key words suchs
    as <param> in web.xml file for a servlet config.
    Example:
    <servlet>
    <servlet-name>testServlet</servlet-name>
    <parameter>
    <param-name>some name</param-name>
    <param-value>some value</param-value>
    </parameter>
    </servlet>
    What should I do if I want to repleace 'some value' with '</param-value>some
    value' and still to prevent the engine to terminate parsing the param-value
    at the fake ending? Is there a standard way in XML to distanguish that?
    (in URL format it can be replaced %xx for some chars).
    ie,
    <param-value> </param-value>some value</param-value>
    where the second </param-value> is the real ending.
    Thank you!
    Gang

    Hi!
    You can use "& lt ;" and "& gt ;" xml entities for that. Or wrap text element in <![CDATA[...]]> section.
    Regards,
    Ignat.

  • Were can i found the bo sdk (i.e .war files) for java

    were can i found the bo sdk  code

    i think first of all i need to deploy the webservices on tomcat, and then i need to follow these steps i think
    To set up your web application
    Create the following directory structure in the web applications directory of your web application server:
    web_application_name
          WEB-INF
             lib
             classes
          crystalreportviewers
    Note: Replace web_application_name with the name of your web application. Your web application will be stored in the web_application_name directory. This is the root directory for the web application and contains all of the files that the web application needs. Your web application directory (web_application_name) should be located in the main web application's directory for your web application server (for Tomcat, this directory is typically called webapps).
    Directory Contents:
    The WEB-INF directory contains all of the support files required for your web application.
    The WEB-INF\lib directory contains all of the JAR files required by your web application.
    The crystalreportviewers directory contains all of the support files required by the viewers.
    Copy the support and library JAR files required for your web application into the WEB-INF\lib directory.
    For details on which JARs to deploy, see JAR files needed for deployment of Business Objects Software.
    Note: Copy the jar files from java\lib\external into WEB-INF\lib; do not copy to WEB-INF\lib\external.
    If you are using scheduling components or a report viewer in your application, deploy the CrystalReports.war file (\Program Files\Business Objects\BusinessObjects Enterprise 12.0\java\applications on Windows) with your web application.
    Create a web.xml file for your web application and save it in the WEB-INF directory (or modify an existing web.xml file if you are adding viewing capability to an existing web application).
    To learn how to set up the web.xml file, see Configuring your web.xml file.

  • How to deploy the web.xml file when trying to use the JSP SDK from SAP?

    I want to use the adduser.jsp which downloaded form SAP SDK samples to add user in BO, but I cannot run it sucessfully. I believe it's caused the web.xml file was not deployed appropriately.
    could you please teach how to deploy the web.xml file for the JSP samples ?
    Could you show me some sample of web.xml for the SDK jsp files? Thank you very much!

    Ensure that you have followed below directory structure while deploying your web application.
       web_application_name
          WEB-INF
             lib
             classes
    web.xml must be placed in WEB-INF. Ensure that you have included all the jar files and other necessary files in your application.
    For more information refer to the below link:
    http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/devsuite.htm
    Regards,
    Anuj

  • Can I run F.19 without posting or do you know of any other transaction

    Can I run F.19 without posting or do you know of any other transaction.
    I run F.19 gives me information on GR/IR by PO number but it appears to want to post a batch when I run it.
    Is their another transaction that would let me reconcile GR/IR by PO number and just gives me the report without posting? Can transaction f.13 in test run achieve this.
    Thanks for your help
    AQ

    Hi,
    You can execute F.19 without posting. To do it, go to Posting tab and remove "Create posting" field. it will give you report without posting it.
    instead of Using F.13,  use FBL3N and in GL account give your GR/IR account.
    It will work....
    Regards,
    Vinod
    If helpful, Please assign the points.

  • Can I run a c5500 without supervisor card

    Customer only has installed ASP in slot 13 in a c5500 and wants to remove the sup3 module.
    Can I run the chassis without supervisor
    in respect of power-,temperature control?

    No, you cannot, it is not possible to operate a C5500 without a supervisor card.

  • How can I run ni488216.exe without any prompts during installation?

    How can I run ni488216.exe without any prompts during installation (Silent mode)?

    Typically you can do a silent install of the NI-488.2 software by running:
    setup.exe /S LV_INSTALL path=
    Regards,
    Greg Caesar
    National Instruments
    Applications Engineer

  • Hi, I got the problem with Firefox 27.0.1. I can not run Selenium on Firefox after login a website for automation testing. The browser is not responding.

    Hi, I got the problem with Firefox 27.0.1. I can not run Selenium on Firefox after login a website for automation testing. The browser is not responding. However when I close Nunit, the page is back to be normal. The title is returned to the name of website without "not responding". I sure this problem did not happen on Firefox version 26. I just got this problem when firefox upgrading automatically to version 27. Please help me fix this problem because it is very important for my work. If you need more information pls send your concerns via my email address.
    Thanks so much

    Hi, the work around suggested above should put you in working mode in the meantime. However to help investigate the issue it is possible to analyze what is not loading or taking a long time by analyzing the network traffic or http headers of the Nunit web page.
    *[https://addons.mozilla.org/en-us/firefox/addon/live-http-headers/]
    *Web developer Tools > Web console
    If you post the results with out the user data, we are happy to help.

Maybe you are looking for