Significance of context param in web.xml to initialize any variable?servlet

I am writing a standalone web appplication for rss (xml) creation where i am having jsp servlets class etc.
Now to write rss.xml and read it back in application i have temporarily used c:\\rss.xml but to make it capable working in web application which can be uploaded in website i need to make it configurable i need to kep it in context param of web.xml and in init() method of servlet of my application what exactly i should do there.what i have tried is this :
public class Startup extends HttpServlet {
private static String rssFeed;
private ServletContext ctx;
Logger log = Logger.getLogger(Startup.class);
public void init(){
log.debug("Initializing APPLICATION CONTEXT Variables");
ctx = getServletContext();
rssFeed = (String)ctx.getInitParameter("RssFeed");
log.debug("Rss : " + rssFeed);
String rssFile = this.getServletContext().getRealPath("") + File.separator + "WEB-INF" + File.separator + "rss.properties";
Properties property = new Properties();
try{
InputStream propertiesFile = new FileInputStream(rssFile);
property.load(propertiesFile);
catch (IOException e) {
log.error("IOException during domainValuesList file Reading");
e.printStackTrace();
log.error("Exception while loading AllowedDomainValues file");
log.debug("Domain Values Lists Updated");
/** Get Host Name (Server Name) where application is hosted on
public static String getRssFeed(){
return rssFeed;
after that i called this startup servlet class in other servlet taken this getRssFeed()
stored it as string passed as parametr to other class where i need to call it but there i am getting null pointer exception which says not initialized.
even what i have written in web.xml is here:
<context-param>
<param-name>RssFeed</param-name>
<param-value>c:\\rsshandler.xml</param-value>
</context-param>
<servlet>
<servlet-name>Startup</servlet-name>
<servlet-class>src.Startup</servlet-class>
<init-param>
<param-name>RssFeedConfig</param-name>
<param-value>/WEB-INF/rss-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Startup</servlet-name>
<url-pattern>/Startup</url-pattern>
<load-on-startup>1</load-on-startup>
</servlet-mapping>
i tried what i know or understood but its not working.
one more thing i have doneis:created rss.properties files in web-inf
lines added are
rssfeed=c:\\rsshandler.xml
but even i am not getting this why
or what sholud i do here.
this thing needs to be configurablewhich we can change later easily.
any suggestions.
thanks
vijendra

Ben -
There can be init params for the servlet or for the servlet context. For the servlet, this looks like:
<servlet>
<servlet-name>InitServlet</servlet-name>
<servlet-class>package1.InitServlet</servlet-class>
<init-param>
<param-name>message</param-name>
<param-value>Hello From Initialization Parameter</param-value>
</init-param>
</servlet>
in the web.xml file, and is accessed using:
public void init(ServletConfig config) throws ServletException
super.init(config);
message = config.getInitParameter("message");
For a servlet context init param, you define it as you did using the web.xml settings editor:
<context-param>
<param-name>hello</param-name>
<param-value>hi</param-value>
</context-param>
This is accessed using:
public void init(ServletConfig config) throws ServletException
super.init(config);
message1 = config.getServletContext().getInitParameter("hello");
Hope this helps,
Lynn
Java Tools Team

Similar Messages

  • Generated JSP reports and context-param in web.xml

    I have what I believe to be a problem when using .jsp files generated from reports builder (actually, it looks as if the problem is in the reports tag library. When adding a context-param to web.xml, I get an error when compiling the following line:
    <%@ taglib uri="/WEB-INF/lib/reports_tld.jar" prefix="rw" %>
    Error(1): oracle.xml.parser.v2.XMLParseException: Invalid element 'context-param' in content of 'web-app', expected elements '[taglib, resource-ref, security-constraint, login-config, security-role, env-entry, ejb-ref]'.
    Note that I can read the context param and no other JSP pages seem to care, just those with the Reports Tag library.
    Regards,
    Jeff

    Ben -
    There can be init params for the servlet or for the servlet context. For the servlet, this looks like:
    <servlet>
    <servlet-name>InitServlet</servlet-name>
    <servlet-class>package1.InitServlet</servlet-class>
    <init-param>
    <param-name>message</param-name>
    <param-value>Hello From Initialization Parameter</param-value>
    </init-param>
    </servlet>
    in the web.xml file, and is accessed using:
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    message = config.getInitParameter("message");
    For a servlet context init param, you define it as you did using the web.xml settings editor:
    <context-param>
    <param-name>hello</param-name>
    <param-value>hi</param-value>
    </context-param>
    This is accessed using:
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    message1 = config.getServletContext().getInitParameter("hello");
    Hope this helps,
    Lynn
    Java Tools Team

  • Realising global Parameters like init-param in web.xml

    Hallo,
    I have a question:
    How can I implement own parameters in a StudioCreator-application.
    I have tried to edit the web.xml, first time it works.
    (I read the parameters with ExternalContext.getInitParameter)
    But later the web.xml was rewrited by the IDE and my parameters are gone.
    Thanks for your help!
    Regards
    Wolfgang

    Hallo,
    I tried both. First the one in build. An than the one in src.
    If I change the name or the Page (with rename)
    my entries in the web.xml disappear.
    My entries are:
    <context-param>
    <param-name>ldap_url_primary</param-name>
    <param-value>ldap://WW004.SIEMENS.NET:389</param-value>
    </context-param>
    <context-param>
    <param-name>domaene</param-name>
    <param-value>WW004.SIEMENS.NET</param-value>
    </context-param>
    <!-- Faces Servlet -->
    Thanks,
    Wolfgang

  • Init-params in web.xml are not loaded (Tomcat 4)

    Hello all...
    I register a servlet in webapps/<my-servlet>/WEB-INF/web.xml file, and pass 1 <init-param> tag. The file gets parsed (I know because when I made errors tomcat complained during initialization). However, when in the init method of the servlet I try to access this parameter, its not there. In fact, the servlet has NO init params at all.
    =================================================
    I have the following web.xml file
    <?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>
    <servlet>
    <servlet-name>XServlet</servlet-name>
    <servlet-class>com.fxcm.xml.xengine.xdas.XServlet</servlet-class>
    <init-param>
    <param-name>xengine.configFile</param-name>
    <param-value>c:/projects/re/das.config/config.xng</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
         <servlet-name>XServlet</servlet-name>
         <url-pattern>/xservlet</url-pattern>
    </servlet-mapping>
    </web-app>
    =======================================================
    I have the following servlet
    * XServlet.java
    * Created on May 6, 2002, 1:17 PM
    package com.fxcm.xml.xengine.xdas;
    import javax.servlet.*;
    import javax.servlet.http.HttpServlet;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletConfig;
    import java.util.Enumeration;
    import com.fxcm.xml.xengine.XEngine;
    public class XServlet extends HttpServlet{
    /** Initiates new XServlet */
    public void init(ServletConfig config)
    throws ServletException
              for (Enumeration e = config.getInitParameterNames(); e.hasMoreElements();){
    //This statement never gets printed because the loop never enters here since there are no init parameters
                   System.out.println(e.nextElement());
    super.init(config);
    String str = config.getInitParameter("xengine.configFile");
    System.out.println(str);
    XEngine.init(str.trim()); //This line throws NullPointer, because str is null since there are no initParameters.
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException{
    // res.setContentType( );
              System.out.println("Got post request in XServlet");
    PrintWriter out = res.getWriter();
    out.println(XEngine.process(req.getInputStream()));
    out.flush();
    out.close();
    ================================================================
    I get the follwoing error in the browser:
    type Exception report
    message Internal Server Error
    description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
         at com.fxcm.xml.xengine.xdas.XServlet.init(Unknown Source)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:918)
         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:655)
         at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:400)
    Please help.
    Thank you,
    Elana

    I know what the problem is. If you call servlet with the default URL (http://host/app/servlet/package.Servlet) than Servlet DOES NOT read init parameters. I don't know why it was designed this way.
    To make servlet read init parameters, you have to assign it a name and then call it with that name, like this:
    <servlet>
    <servlet-name>ServletName</servlet-name>
    <servlet-class>package.ServletClass</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ServletName</servlet-name>
    <url-pattern>/app/path/ServletName</url-pattern>
    </servlet-mapping>
    You can then call servlet using path specified in url-pattern and read init parameters in the normal way.

  • Access context parameter in web.xml

    Hi, all. I add a entry into Context Initialization parameter at tab Application in file web.xml with name: path and value img/product. I don't know how to get the context parameter. I want access the context by EL in file .jspx or .jsf, as #{path} but error. Can anyone help me.Thanks.

    Hi,
    have a go with
    #{initParam['param_name_here']}"
    alternatively
    #{facesContext.externalContext.initParameterMap['param_name_here']}
    Frank

  • 9.0.3, web.xml, context-param

    Using documentation found on oracle's website, where I needed to have a specific initialization parameter, I setup a context-param in web.xml. In 9.0.2, I got a warning (and posted here but got no response) but was able to continue. In 9.0.3 I can't run my project when I include this parameter.
    Here's what I add to web.xml
    <context-param>
    <param-name>ReportServerURL</param-name>
    <param-value>http://localhost:8888/reports/rwservlet</param-value>
    </context-param>
    when trying to compile, I get:
    Error(76,18): Invalid element 'context-param' in content of 'web-app', expected elements '[taglib, resource-ref, security-constraint, login-config, security-role, env-entry, ejb-ref]'.
    Any ideas?
    Thanks,
    Jeff

    If only you would see web-app.dtd you could know that context-param must be enclosed in web-app and be at certain place. See that (from web-app.dtd):
    <!ELEMENT web-app (icon?, display-name?, description?, distributable?,
    context-param*, filter*, filter-mapping*, listener*, servlet*,
    servlet-mapping*, session-config?, mime-mapping*, welcome-file-list?,
    error-page*, taglib*, resource-env-ref*, resource-ref*, security-constraint*,
    login-config?, security-role*, env-entry*, ejb-ref*, ejb-local-ref*)>

  • Problem in using context param for storing database connection information

    Hello Friends,
    I am new to struts & jsp.I am developing a project in struts.I have 1 jsp page called editProfile.jsp.On submitting this page it will call 1 action class.The action class in turn will call the Plain old java class where I have written the logic for updating User Profile.
    I have created context-param in web.xml for database connection information like dbURL , dbUserName , dbPassword , jdbcDriver.Now I want to use these connection information in my Business logic(Plain Old Java Class).As we can use context parameter only in jsp & servlets , I am setting the variables of my business logic class with these context param in jsp itself.
    now when I am calling the updateProfile method of Business logic class from Action class it is giving error as all the connection variables which I set in jsp for my business logic class has become null again.
    I am not getting.If once I have set those variables how come they are becoming null again???Please help me.Any Help will be highly appreciated.Thanx in advance.

    This is the code I have written
    web.xml file
    <context-param>
    <param-name>jdbcDriver</param-name>
    <param-value>oracle.jdbc.driver.OracleDriver</param-value>
    </context-param>
    <context-param>
    <param-name>dbUrl</param-name>
    <param-value>jdbc:oracle:thin:@localhost:1521:gd</param-value>
    </context-param>
    <context-param>
    <param-name>dbUserName</param-name>
    <param-value>system</param-value>
    </context-param>
    <context-param>
    <param-name>dbPassword</param-name>
    <param-value>password</param-value>
    </context-param>
    EditProfile.jsp
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ page import="java.sql.*" %>
    <jsp:useBean id="EditProfile" scope="application"
    class="com.myapp.struts.EditProfile"/>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Edit My Profile</title>
    </head>
    <body>
    <form action="submitEditProfileForm.do" focus="txt_FirstName" method="post">
    <%
    EditProfile.setjdbcDriver(application.getInitParameter("jdbcDriver"));
    EditProfile.setdbURL(application.getInitParameter("dbURL"));
    EditProfile.setdbUserName(application.getInitParameter("dbUserName"));
    EditProfile.setdbPassword(application.getInitParameter("dbPassword"));
    -----------more code goes here------------
    EditActionProfile.java
    package com.myapp.struts;
    import javax.servlet.jsp.jstl.core.Config;
    import org.apache.struts.action.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class EditProfileAction extends Action {
    public EditProfileAction()
    public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception
    try
    if (isCancelled(request))
    return mapping.findForward("mainpage");
    EditProfileForm epf = (EditProfileForm)form;
    EditProfile ep = new EditProfile();
    String temp = ep.updateProfile(epf.getTxt_FirstName(),epf.getTxt_MiddleName() , epf.getTxt_LastName() , epf.getTxt_Address() , epf.getTxt_Email() );
    if(temp.equals("SUCCESS"))
    return mapping.findForward("success");
    else
    return mapping.findForward("failure");
    catch(SQLException e)
    System.out.println("error" + e.getMessage());
    return mapping.findForward("failure");
    EditProfile.java class (My Business Logic Class)
    package com.myapp.struts;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.sql.*;
    public class EditProfile {
    private String dbURL;
    private String dbUserName , jdbcDriver;
    private String dbPassword;
    private Connection con;
    private Statement stmt;
    public EditProfile()
    public void setdbURL(String s )
    this.dbURL = s;
    public void setdbUserName(String s )
    this.dbUserName = s;
    public void setdbPassword(String s )
    this.dbPassword = s;
    public void setjdbcDriver(String s )
    this.jdbcDriver = s;
    public String updateProfile(String firstname , String middlename , String lastname , String address , String email)
    throws SQLException, ClassNotFoundException , java.lang.InstantiationException , IllegalAccessException
    try
    String s1 = new String("update usr set first_name='" + firstname + "' , middle_name='" + middlename + "' , last_name='" + lastname +"' , address='" + address + "' , email_id='" + email + "' where usr_key=1" );
    con = this.init();
    System.out.println("after init");
    stmt = con.createStatement();
    int rslt = stmt.executeUpdate(s1);
    System.out.println("after excute update");
    stmt.close();
    if(rslt>=1)
    return "SUCCESS";
    else
    return "Failure";
    finally
    if (null != con)
    con.close();
    public Connection init() throws SQLException, ClassNotFoundException
    Class.forName(jdbcDriver);
    con = DriverManager.getConnection(dbURL, dbUserName, dbPassword);
    return con;
    public void close(Connection connection) throws SQLException
    if (!connection.isClosed())
    connection.close();
    }

  • C:import and web.xml

    Im using <c:import url="http://path_to_html" />. I want to put this value in the web.xml using context param. The problem is I don't know how my c:import tag will refer to that context param inside web.xml. Can anyone give a solution? Thanks.

    web.xml
      <context-param>
        <param-name>abc</param-name>
        <param-value>http://path_to_html</param-value>
      </context-param>
    JSP
    <c:import url="<%= application.getInitParameter("abc") %>"></c:import>More info for c:import
    http://www.onjava.com/pub/a/pub/a/onjava/2002/05/08/jstl.html?page=2
        * Absolute URL: <c:import url="http://sample.com/Welcome.html"/>
        * Relative URL (to the current context): <c:import url="/copyright.html"/>
        * Relative URL with a foreign context: <c:import url="/myLogo.html" context="/common"/>
        * FTP resource: <c:import url="ftp://ftp.sample.com/myFile"/>

  • Web.xml problem ????

    This is my web.xml file :==>
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
    <web-app>
    <servlet>
    <servlet-name>chatAdmin</servlet-name>
    <servlet-class>ChatAdminServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>chatRoom</servlet-name>
    <servlet-class>ChatRoomServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>listRooms</servlet-name>
    <servlet-class>ListRoomsServlet</servlet-class>
    </servlet>
    <context-param>
    <param-name>ADMIN_PATH</param-name>
    <param-value>/ChatApplication/servlet/chatAdmin</param-value>
    </context-param>
    <context-param>
    <param-name>LISTROOMS_PATH</param-name>
    <param-value>/ChatApplication/servlet/listRooms</param-value>
    </context-param>
    <context-param>
    <param-name>CHATROOM_PATH</param-name>
    <param-value>/ChatApplication/servlet/chatRoom</param-value>
    </context-param>
    </web-app>
    Error after starting Tomcat in above file:-
    Starting service Tomcat-Standalone
    Apache Tomcat/4.0.1
    PARSE error at line 38 column 11
    org.xml.sax.SAXParseException: The content of element type "web-app" must match "(icon?,display-name?,description?,
    distributable?,context-param*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page
    *,taglib*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*)".
    Starting service Tomcat-Apache
    Apache Tomcat/4.0.1
    I am not getting where is error exactly please inform .

    <web-app>
    <servlet>
    <servlet-name>chatAdmin</servlet-name>
    <servlet-class>ChatAdminServlet</servlet-class>
    </servlet>[snip]
    <context-param>
    <param-name>ADMIN_PATH</param-name>
    <param-value>/ChatApplication/servlet/chatAdmin</param>
    </context-param>
    [snip]
    org.xml.sax.SAXParseException: The content of element
    type "web-app" must match
    "(icon?,display-name?,description?,
    distributable?,context-param*,servlet*,servlet-mapping*
    session-config?,mime-mapping*,welcome-file-list?,error-
    ageThe error message specifies exactly what is wrong -- namely your context-param tags need to come before your servlet tags which need to come before your servlet-mapping tags, etc...
    ncuka

  • Question on web.xml in OAF

    Hi Friends,
    when i open web.xml in jdeveloper window, i can able to see my application(instance) user name and pass word.
    what can i do to remove my password in web.xml. is there any set up to do for instead of displaying password name display as some *****************.
    Thanks in advance,
    vamshi.

    Hi Reetesh,
    Thank you.
    atleat can we hide this below part in web.xml..
    <context-param>
    <param-name>OA_LOGIN_PASSWORD</param-name>
    <param-value>krishna12</param-value>
    </context-param>
    Regards,
    vamshi.

  • XCM configuration path in web.xml file

    Hi,
    Here is a requirement that all the XCM configuration files are stored at local desktop(like QAT, PRD..), and need to use them by modifying web.xml.
    Please let me know at
    1)which web.xml tag the path of XCM confiuration files to be specified.
    2) specify the names of the XCM files for configuration to be put in that folder.
    Thanks,
    Devender V

    Hi,
    1)which web.xml tag the path of XCM confiuration files to be specified.
    Try to find below lines in your web.xml
    <context-param>
            <param-name>path.xcm.config.isa.sap.com</param-name>
            <param-value>/WEB-INF/xcm/sap/system/bootstrap-config.xml</param-value>
            <description>Turns the Extended Configuration Management on if a
                path to the configuration file is specified. It is a
                relative path, with context-root of web application as root</description>
        </context-param>
    bootstrap-config.xml file contains XCM configuration related XML file path. You can modify or extend this file and give your user Define path.
    Also you can find below line in web.xml file.
    <!-- Action Servlet Configuration -->
        <servlet>
            <servlet-name>action</servlet-name>
            <servlet-class>com.sap.isa.core.ActionServlet</servlet-class>
            <init-param>
                <param-name>config</param-name>
                <param-value>/WEB-INF/config.xml,/WEB-INF/xcmadmin-config.xml,/WEB-INF/ccmsims-config.xml,/WEB-INF/ipc-config.xml,/ipc/customer/config.xml,/WEB-INF/config_lwc_b2b.xml,/WEB-INF/scheduler-config.xml,/WEB-INF/ipcpricing-config.xml</param-value>
            </init-param>
            <init-param>
                <param-name>config/user</param-name>
                <param-value>/WEB-INF/config_user.xml</param-value>
            </init-param>
            <init-param>
                <param-name>config/dealerlocator</param-name>
                <param-value>/WEB-INF/config_dealerlocator.xml</param-value>
            </init-param>
            <init-param>
                <param-name>initconfig</param-name>
                <param-value>/WEB-INF/xcm/sap/system/init-config.xml</param-value>
            </init-param>
    I hope this will help you.
    eCommerce Developer

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

  • Using a Variable from web-inf/web.xml in java code?

    I would like to create a read-only variable with a value in the /web-inf/web.xml file and then access that value within a java service method within the Application Module.
    Where / how do I read the value from the web.xml file and make it accessible within my java code?
    thanks

    Hi,
    you can define context parameters in web.xml that you can access from Java in the web application
    The following is a JSF examle that checks a context parameter in a PhaseListener, where the string is stored ina Java constant (could be "myParam")
    ExternalContext exctx = FacesContext.getCurrentInstance().getExternalContext();
    useSessionPageCache = exctx.getInitParameter(Constants.USE_PAGE_CACHE) == null ? false :
    (exctx.getInitParameter(Constants.USE_PAGE_CACHE)).equalsIgnoreCase("TRUE") ? true : false;
    From here you can call a method on the AM to set the value or look for another option.
    Frank

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

  • Web.xml file

    Hi
    I have a servlet that is working perfectly through JBuilder. When I try and run it through Tomcat I get an error saying it cannot find the file. In JBuilder I have a html form. The value entered in the form is passed to the servlet. The servlet calls Java classes from a different package. The servlet uses the value from the form as the paramater needed for the classes in the other package and outputs the results.
    I cannot get this working outside JBuilder.
    It could be something to do with the web.xml file. I tried copying the webapp folder from the JBuilder servlet project straight across to Tomcat but it didnt work. This project has its own WEB-INF folder and web.xml file. Should this work or do I need to change the Tomcat web.xml file.
    Any help
    Damul

    Hai,
    First you are taking the parameter value from the HTML page, pass it to the package class and show the out put.
    Fine, to run in Tomcat 4.1.24,first you have to create a context of yours.
    Else you can place your class files or package in the folder
    'examples' of webapps in Tomcat directory.
    Now place your HTML file in 'examples' folder.
    One more thing you have to include your package class name in the web.xml for the new context,if you create.Else if you place in the 'examples' folder , no need to edit web.xml
    to run this, for your package
    http://localhost:8080/examples/servlet/<packagename>.<classname>
    Hope this works out...

Maybe you are looking for

  • Packing in Outbound Delivery

    Hello All, Please I need urgent help for this error am getting. I created a sales order at the point of doing packing with reference to an existing handling unit, the system says "No material to be packed found, or quantity to be packed equals zero M

  • Host of problems on a refurbished Macbook OS X 10.4

    I recently bought a refurbished macbook os x from surpluscomputers.com. I have always used a windows pc so the past week has been mostly me trying to get aquainted with how a mac works. There are several things on here that just don't seem right and

  • Value mapping in UDF?

    Hi Guys, Is it possible to do the value mapping in a UDF. ReceiverService at runtime - X --> Value mapping not maintained ReceiverService - Y ---> Value mapping maintained.  I want to use this receievr service. There are more than 300 VM groups and i

  • Portal Groups vs. ABAP Roles

    Hi, We have the following scenario: SAP EP (6.0 SP19) with content from BW and HR (ESS&MSS). The backend systems and the portal use CUA. The problem is that for example when a new user(employee) is created in HR, we would like that the user automatic

  • Every time I try to use Netflix instant play the browser closes with no explanation.

    Every time I click on a link for a Netflix instant-play movie, the browser instantly closes all windows and tabs (quits, in fact) with no explanation. The rest of the processes on the computer are not noticeably disturbed. I use Firefox version 3.6.3