Is web.xml necessary?

Is it necessary to have a web.xml file?
The Tomcat examples work fine but on trying some very simple examples from a book I just keep getting a 404 error. As far as I can see I have put the necessary files (with the exception of web.xml) in the correct directories. Thus, I have in WebApps:
dir Test1
dir servlets with the HTML file
dir Web-inf > dir classes with the HTTPGetServlet.classThe URL is: http://localhost:8080/Test1/HTTPGetServlet
JSDK 1.4
Tomcat 3.2.3
Cheers.
Alan

Well, you must have web.xml on your application otherwise where are you going register your servlets.
That's why everytime you create a servlet you must register it in your web.xml like this:
<?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>Servlet</servlet-name>
<servlet-class>YourServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet</servlet-name>
<url-pattern></url-pattern>
</servlet-mapping>
</web-app>
Where <servlet-name> is like a nickname of your class YourServlet.
One point, if your servlet is inside a package you will have to put it in the tag in the same way:
<servlet>
<servlet-name>Servlet</servlet-name>
<servlet-class>yourpackage.YourServlet</servlet-class>
</servlet>
I sincerly hope to help you.
Douglas from Italy.

Similar Messages

  • J2EE Engine - Restart necessary after changing web.xml?

    Hi people,
    do I have to restart the whole J2EE Engine after changing the <max-sessions> parameter of my J2EE-App? Or is a restart of the app via the deploy service also sufficient?
    This parameter change is done in web.xml on 620 and web-j2ee-engine.xml in 640.
    Thanks!
    Bjoern
    Message was edited by: Bjoern Altmannsberger

    restart only the application via deploy service
    regards,
    Violeta

  • How to create a simple web.xml for using servlets

    Hello i wanna configure the web.xml that i can use sevlets and beans, but how can i do that?
    This is de directorie i have installed my webapp
    C:\Tomcat 4.1\webapps\testapp
    C:\Tomcat 4.1\webapps\test\WEB-INF\classes (in this dir, I wanna put my beans and servlets, I got one servlet and the name is LogIn.class).
    And i wanna request my servlets with the url http://localhost:8080/testapp/servlet/LogIn
    How can i create a very basic web.xml with working beans, servlets and session? It is for testing-use only, so the security is not important for me at this moment.
    Tnx

    under your web-inf
    in your web.xml file you must map
    the servlets
    under the <web-app> tag type
    <servlet>
         <servlet-name>LogIn</servlet-name>
         <servlet-class>com.LogIn</servlet-class>
    </servlet>
    <servlet-mapping>
          <servlet-name>LogIn</servlet-name>
          <url-pattern>/LogIn</url-pattern>
    </servlet-mapping>ps: start using some IDE such as NetBeans or Ecclipse
    since they will take care of mapping all servlets and Beans
    and generate all the necessary files for your web-app

  • Do we need to put the following code in the web-xml for the project to run

    Hi^^^,
    actually I have created a project in Eclipse WTP and I am running it from remote server. Its giving me 404 error when I tried to run it.
    I know 404 error is generally due to some error in deployment descriptor.
    I am going through this tutorial for creating project in eclipse WTP
    this says that I need to include the following code in web-xml. Please look at the quotes below
    "Web modules in J2EE has a deployment descriptor where you configure the web application and its components. This deployment descriptors is called the web.xml. According to the J2EE specification, it must be located in the WEB-INF folder. web.xml must have definitions for the Servlet and the Servlet URI mapping. Enter the following lines into web.xml:"
    "Listing 2. Deployment Descriptor web.xml"
    <servlet>
    <servlet-name>Snoop Servlet</servlet-name>
    <servlet-class>org.eclipse.wtp.tutorial.SnoopServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Snoop Servlet</servlet-name>
    <url-pattern>/snoop/*</url-pattern>
    </servlet-mapping>
    My question is, it is necessary to include the above lines between <servlet> and </servlet-mapping> in web-xml
    thanks and regards,
    Prashant

    pksingh79 wrote:
    actually I have created a project in Eclipse WTP and I am running it from remote server. Its giving me 404 error when I tried to run it.
    I know 404 error is generally due to some error in deployment descriptor. what's the url you've put.
    <servlet>
    <servlet-name>Snoop Servlet</servlet-name>
    <servlet-class>org.eclipse.wtp.tutorial.SnoopServlet</servlet-class>
    </servlet> Every Servlet has to have a <servlet></Servlet> tag in the web.xml
    the <servlet-name>is for the naming the servlet and the <servlet-calss>is for class file of the servlet in your case the .class file is to be in the package of tutorial,if it's not then how the container will no where the calss file is
    <servlet-mapping>
    <servlet-name>Snoop Servlet</servlet-name>
    <url-pattern>/snoop/*</url-pattern>
    </servlet-mapping>You type something in your url likk http://localhost:8080/webappname (Tomcat server),so for url mapping instead of typing the entire class file name ,you just enough have to type what you've put in the <url-mapping> tag and it has to be inside of <servlet-mapping>
    I think the problem is in <url-pattern> change it like /snoop<url-pattern>
    My question is, it is necessary to include the above lines between <servlet> and ></servlet->mapping> in web.xmlSo now you think whether you need something inside <servlet>and </servlet-mapping>

  • Data source needs to be specified in context.xml instead of web.xml - why?

    Hi,
    I'm using a Spring JndiObjectFactoryBean to create my JNDI data source in my code:
    <bean id="jndiDataSource" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">
              <property name="jndiName" value="java:comp/env/jdbc/DS_OURDB_DB2" />
              <property name="lookupOnStartup" value="false"/>
              <property name="proxyInterface" value="javax.sql.DataSource"/>
         </bean>I have the necessary Resource added to my Tomcat's server.xml:
    <Resource accessToUnderlyingConnectionAllowed="false"
                defaultAutoCommit="true" defaultReadOnly="false"
                driverClassName="com.ibm.db2.jcc.DB2Driver"
                factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
                initialSize="0" logAbandoned="false" maxActive="8"
                maxIdle="8" maxOpenPreparedStatements="0" maxWait="-1"
                minEvictableIdleTimeMillis="1800000" minIdle="0"
                name="jdbc/DS_OURDB_DB2" numTestsPerEvictionRun="3"
                password="ourpass" poolPreparedStatements="false"
                removeAbandoned="false" removeAbandonedTimeout="300"
                testOnBorrow="true" testOnReturn="false"
                testWhileIdle="false" timeBetweenEvictionRunsMillis="-1"
                type="javax.sql.DataSource"
                url="jdbc:db2://machine1:60056/DBD1" username="ouruser"
                   validationQuery="SELECT current date FROM sysibm.sysdummy1"/>I then have the resource referenced in my web.xml:
    <resource-ref>
              <res-ref-name>jdbc/DS_OURDB_DB2</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
              <res-sharing-scope>Shareable</res-sharing-scope>
         </resource-ref>However, I'm getting JndiLookupFailureExceptions when I attempt to use this JNDI resource.
    I can resolve it by specifying the following in my META-INF/context.xml:
    <Context>
         <ResourceLink global="jdbc/DS_OURDB_DB2" name="jdbc/DS_OURDB_DB2" type="javax.sql.Datasource"/>
    </Context>I've read some of the JNDI/Tomcat documentation. However, I still do not understand why it doesn't work with the web.xml. Can anyone explain please? Thanks

    Can answer this myself after some more investigation. The reason I required the entry in the META-INF/context.xml was because I had specified the Resource as a Global Reference in the server.xml. By adding this Resource to my application's Context in the server.xml the configuration in the web.xml worked as expected.

  • How to generate web.xml automatically?

    Hi all!
    I am new to servlets. I have configured the tomcat 5.5.9 with eclipse 3.0 succussfully. It is generating the class files. But I want to know how to generate web.xml through it.
    Thanks in advance...
    Code Snooker

    AFAIK, there's no template for generating web.xml.
    Navigate to <TomcatInstallDir>/webapps/
    You would find lot of directories - each one being a web application.
    Navigate to any one, say ROOT and then to the WEB-INF directory
    under that.
    You would find a web.xml.
    Copy it into your <web-application-dir>/WEB-INF folder and make necessary changes
    cheers,
    ram.

  • Web.xml - adjusting the session configuration

    I recently applied SP07 for NW7.01 to one of our portals, and since doing this I can not find where to make adjustments for the session timeout. It used to be defined in the web.xml, does anyone know where it was moved to?
    I used to go here:
    /usr/sap/<SID>/JC##/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/web-inf/web.xml and adjust the default of 30 as necessary. Where is this value found now?
    I can also make the adjustment from the visual administrator under web container> properties> Session Timeout and this requries a restart of the web container service.
    From SAP HELP:
    Specifying HTTP Session Timeout 
    You can specify a timeout period for HTTP sessions created in your Web application. If the session is inactive for this timeout period, it is invalidated by the Web container.
    If you do not specify such a timeout explicitly, a default one of 30 minutes is assumed.
    You can configure the HTTP session timeout using the web.xml descriptor.
    Procedure
    On the web.xml screen, proceed as follows:
           1.      Open the General screen.
           2.      To specify the timeout period, enter a value in the Session configuration u2013 Session timeout field.
    The value is specified in minutes. If you enter a negative value in this field, HTTP sessions are never terminated because of a timeout. Instead, only an explicit logout by the user will terminate the corresponding session.

    Hello David.
    The help article is about custom development using NWDS. For adjusting session timeout system wide refer to Re: Portal session time out is 30 minutes.
    Best regards,
    Aliaksandr Zhukau

  • 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

  • Help with web.xml under WL5.1sp3

    Hello,
    I just started to explore Weblogic Server 5.1sp3 as part
    of setting it up for the JASIG uPortal project here at UBC.
    I'm unable to get web.xml to work for me. I've created the
    file, I know WL is seeing it and parsing it (through various
    typos during the installation process) but when my index.jsp page
    runs, getInitParameter() comes back with nothing.
    Any ideas what I could be missing?
    Thanks
    George
    [email protected] ITServices, UBC
    Programmer/Analyst
    phone: 604.822.4375 fax: 604.822.5116

    Please post this to the weblogic.developer.interest.servlet
    thanks
    mbg
    In article <[email protected]>, [email protected] says...
    Hello,
    I just started to explore Weblogic Server 5.1sp3 as part
    of setting it up for the JASIG uPortal project here at UBC.
    I'm unable to get web.xml to work for me. I've created the
    file, I know WL is seeing it and parsing it (through various
    typos during the installation process) but when my index.jsp page
    runs, getInitParameter() comes back with nothing.
    Any ideas what I could be missing?
    Thanks
    George
    ==================================================
    NewsGroup Rant
    ==================================================
    Rant 1.
    The less info you provide about your problem means
    the less we can help you. Try to look at the
    problem from an external perspective and provide
    all the data necessary to put your problem in
    perspective.

  • Override web.xml With Server Specific Values

    Not sure if here or the OC4J/J2EE forum is most appropriate place for this question:
    We're currently working on migrating from the old jserv setup to 9.0.4 app server with OC4J. We have the infrastructure installed and are managing the application through Enterprise Manager. In my web.xml file I provide initialization parameters to one of my servlets using something similar to the following:
    <servlet>
    <servlet-name>util.GlobalPropertyManager</servlet-name>
    <servlet-class>util.GlobalPropertyManager</servlet-class>
    <init-param>
    <param-name>mhris.batch.outputdir</param-name>
    <param-value>d:/dev/java/mhris/defaultroot/batch/</param-value>
    </init-param>
    </servlet>
    Now, this directory path I've provided is only good on my local workstation. When I deploy to my UNIX production servers, I need to override this with a valid path depending on the server being deployed to (no, they don't all have the same directory setup, yeah it's a pain). These servers include our production boxes, development server, test, training, etc.
    Currently under JSERV, I provide server specific values in the Global Init Parameters section of my property file (don't remember why we didn't use the Servlet Init Parameters property instead). This works very well since this file is not touched when we land updates, so the values are set once for each server.
    Under OC4J, I understand that I can override the values in web.xml by using an orion-web.xml file BUT it appears that this file resides in the WAR I deploy, so each server will get the same orion-web.xml rather than maintaining its own set of values.
    Is there another .xml file I can use to provide these initalization parameters? global-web-applications.xml looked promising but I wasn't completely sure I could put values for my application in it or where exactly they should go (ie. inside the existing <web-app> section or if I should create a second one specifically for my app).
    Any ideas or will I have to reploy a different orion-web.xml file to each of my servers?
    Appreciate the assistance,
    Michael

    Michael,
    First, I would just modify the web.xml during each deployment.
    Second, I would recommend using the same relative path with the web-app context. Then, you can use the Servlet API to retrive the real path of the web-app context.
    I don't think it is necessary to use orion-web.xml or other properties files.

  • WAR Deployment Problem (WEB-INF/web.xml not found)

              I have a war application and WebLogic 5.1 with Svr Pack 8 failed to deploy it
              when it start up. Here is what I did,
              1. I jared all necessary files including WEB-INF\web.xml in the myapp.war file;
              here I used all uppercase for WEB-INF directory, but after I jared it, it shew
              up web-inf\web.xml but WEB-INF\lib\pushlet.jar in the myapp.war file. I think
              this is the behavior of jar program.
              2. I appended the myapp.war to the weblogicclasspath in the start script;
              3. In weblogic.properties file, I specified two lines:
              weblogic.httpd.webApp.myapp=c:/weblogic/default/myapp.war
              weblogic.httpd.defaultWebApp=myapp
              4. Then I start up the WebLogic server named "default". It shew the following
              error messages:
              java.io.FileNotFoundException: Directory myapp\ does not contain WEB-INF/web.x
              ml
              at weblogic.servlet.internal.dd.DescriptorLoader.<init>(DescriptorLoader
              .java:177)
              at weblogic.t3.srvr.HttpServer.loadWARContext(HttpServer.java:630)
              at weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java:558)
              at weblogic.t3.srvr.HttpServer.start(HttpServer.java:418)
              at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:1312)
              at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:827)
              at java.lang.reflect.Method.invoke(Native Method)
              at weblogic.Server.startServerDynamically(Server.java:99)
              at weblogic.Server.main(Server.java:65)
              at weblogic.Server.main(Server.java:55)
              Thu Mar 29 17:24:16 EST 2001:<E> <HTTP> FATAL: could not load WAR 'myapp' as d
              efault servlet context
              java.lang.NullPointerException
              at weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java:560)
              at weblogic.t3.srvr.HttpServer.start(HttpServer.java:418)
              at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:1312)
              at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:827)
              at java.lang.reflect.Method.invoke(Native Method)
              at weblogic.Server.startServerDynamically(Server.java:99)
              at weblogic.Server.main(Server.java:65)
              at weblogic.Server.main(Server.java:55)
              Thu Mar 29 17:24:17 EST 2001:<E> <HTTP> Could not find Web application 'c:/weblo
              gic/default/myapp.war'
              java.io.FileNotFoundException: WEB-INF/web.xml XML file not found in jar file
              at weblogic.xml.dom.DOMParser.getDocument(DOMParser.java:93)
              at weblogic.servlet.internal.dd.DescriptorLoader.<init>(DescriptorLoader
              .java:134)
              at weblogic.t3.srvr.HttpServer.loadWARContext(HttpServer.java:627)
              at weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java:602)
              at weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java:570)
              at weblogic.t3.srvr.HttpServer.start(HttpServer.java:418)
              at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:1312)
              at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:827)
              at java.lang.reflect.Method.invoke(Native Method)
              at weblogic.Server.startServerDynamically(Server.java:99)
              at weblogic.Server.main(Server.java:65)
              at weblogic.Server.main(Server.java:55)
              Please help me find out what is wrong with this. Greatly Appreciated.
              Thanks in advance,
              Donald
              

              If it is still not working, try to set the weblogic.httpd.documentRoot =c:/weblogic/default
              in the weblogic.properties & try.
              "Donald Ye" <[email protected]> wrote:
              >
              >
              >I have a war application and WebLogic 5.1 with Svr Pack 8 failed to deploy
              >it
              >when it start up. Here is what I did,
              >
              >1. I jared all necessary files including WEB-INF\web.xml in the myapp.war
              >file;
              >here I used all uppercase for WEB-INF directory, but after I jared it,
              >it shew
              >up web-inf\web.xml but WEB-INF\lib\pushlet.jar in the myapp.war file.
              >I think
              >this is the behavior of jar program.
              >
              >2. I appended the myapp.war to the weblogicclasspath in the start script;
              >
              >3. In weblogic.properties file, I specified two lines:
              >weblogic.httpd.webApp.myapp=c:/weblogic/default/myapp.war
              >weblogic.httpd.defaultWebApp=myapp
              >
              >4. Then I start up the WebLogic server named "default". It shew the following
              >error messages:
              >
              >java.io.FileNotFoundException: Directory myapp\ does not contain WEB-INF/web.x
              >ml
              > at weblogic.servlet.internal.dd.DescriptorLoader.<init>(DescriptorLoader
              >.java:177)
              > at weblogic.t3.srvr.HttpServer.loadWARContext(HttpServer.java:630)
              > at weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java:558)
              > at weblogic.t3.srvr.HttpServer.start(HttpServer.java:418)
              > at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:1312)
              > at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:827)
              > at java.lang.reflect.Method.invoke(Native Method)
              > at weblogic.Server.startServerDynamically(Server.java:99)
              > at weblogic.Server.main(Server.java:65)
              > at weblogic.Server.main(Server.java:55)
              >
              >Thu Mar 29 17:24:16 EST 2001:<E> <HTTP> FATAL: could not load WAR 'myapp'
              >as d
              >efault servlet context
              >java.lang.NullPointerException
              > at weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java:560)
              > at weblogic.t3.srvr.HttpServer.start(HttpServer.java:418)
              > at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:1312)
              > at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:827)
              > at java.lang.reflect.Method.invoke(Native Method)
              > at weblogic.Server.startServerDynamically(Server.java:99)
              > at weblogic.Server.main(Server.java:65)
              > at weblogic.Server.main(Server.java:55)
              >
              >Thu Mar 29 17:24:17 EST 2001:<E> <HTTP> Could not find Web application
              >'c:/weblo
              >gic/default/myapp.war'
              >java.io.FileNotFoundException: WEB-INF/web.xml XML file not found in
              >jar file
              > at weblogic.xml.dom.DOMParser.getDocument(DOMParser.java:93)
              > at weblogic.servlet.internal.dd.DescriptorLoader.<init>(DescriptorLoader
              >.java:134)
              > at weblogic.t3.srvr.HttpServer.loadWARContext(HttpServer.java:627)
              > at weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java:602)
              > at weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java:570)
              > at weblogic.t3.srvr.HttpServer.start(HttpServer.java:418)
              > at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:1312)
              > at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:827)
              > at java.lang.reflect.Method.invoke(Native Method)
              > at weblogic.Server.startServerDynamically(Server.java:99)
              > at weblogic.Server.main(Server.java:65)
              > at weblogic.Server.main(Server.java:55)
              >
              >
              >Please help me find out what is wrong with this. Greatly Appreciated.
              >
              >Thanks in advance,
              >
              >Donald
              

  • WEB.XML gives me an error while deploying a Web Application in Weblogic 5.1

    I have a Web.xml which I copied the one from their documentation and edited for my servlet specific data. When I try to deploy it I am getting the following error.
              Wed Nov 15 17:10:37 EST 2000:<E> <HTTP> Error reading Web application 'C:/tomcat
              /webapps/La/'
              java.net.UnknownHostException: java.sun.com
              Can you throw some light on this? I have included the first three lines from the WEB,XML file where weblogic is choking.
              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN'
              'http://java.sun.com/j2ee/dtds/webapp_2_2.dtd'>
              Thank You
              Trisula P. Siripurapu
              

              Hi Jacek,
              Thank you for your suggestion. I changed the Web App version to 1.2 instead of 2.2. It worked. Thanks once again for the timely response. I really do appreciate it.
              Trisula Pani Siripurapu.
              Jacek Laskowski <[email protected]> wrote:
              >"Trisula P. Siripurapu" wrote:
              >>
              >> I have a Web.xml which I copied the one from their documentation and edited for my servlet specific data. When I try to deploy it I am getting the following error.
              >> Wed Nov 15 17:10:37 EST 2000:<E> <HTTP> Error reading Web application 'C:/tomcat
              >> /webapps/La/'
              >> java.net.UnknownHostException: java.sun.com
              >
              >I remember having the same problem before I added the latest service
              >pack (SP 6). If you don't want to download it, just change DOCTYPE to
              >
              ><!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application
              >1.2//EN' 'http://java.sun.com/j2ee/dtds/webapp_2_2.dtd'>
              >
              >and it should work. Notice the change of Web Application version - 1.2
              >rather then 2.2. I'm (almost) sure, I saw one example - examples/webapp
              >(?) - with this header. Take a look at the accompanying examples.
              >
              >When you apply SP6, things should work as they suppose to.
              >
              >> Trisula P. Siripurapu
              >
              >Jacek Laskowski
              

  • Web application and web.xml

    i have a web application consisting of 1 servlet and 5 jsps.
    the start point would be index.jsp
    i use firmwide login page. after login, i want the browser to display index.jsp page.
    In web.xml, i have defined -
    <welcome-file-list>          <welcome-file>/jsp/index.jsp</welcome-file>     </welcome-file-list>       <servlet>        <servlet-name>UtilitiesServlet</servlet-name>        <servlet-class>com.gs.fw.sox404.utilities.UtilitiesServlet</servlet-class>             <init-param>             <param-name>util-log4j-init-file</param-name>             <param-value>/WEB-INF/classes/util_log4j.properties</param-value>          </init-param>        <load-on-startup>1</load-on-startup>    </servlet>     <servlet-mapping>        <servlet-name>UtilitiesServlet</servlet-name>        <url-pattern>/UtilitiesServlet</url-pattern>    </servlet-mapping>if i define it as just index.jsp in the welcome file list, after successful login, it displays the dir structure of the web app.
    if i define it as jsp/index.jsp, then in some of the pages, it tries to find the servlet inside jsp folder.
    What would be the best way to get around this?

    Well, yes, it's not able to find it because you've not understood the mechanism of how it works clearly. You have to put your welcome file under every directory you want it to be used from. Like I said, it's not a path, it's a filename. So if the container sees that your request URL is for a directory, it'll look for the welcome files from the welcome file list, one by one, in the order of declaration. Whichever one it finds first, it'll serve that. If it doesn't find any, then it'll either give a 404 or a directory listing depending on the server and it's settings.
    So your problem is that you've put your index.jsp in your JSP folder but expect it to be served for all URLs. That won't happen, you'll have to put one file named index.jsp into every directory. The reasoning is pretty simple, what if you want different behaviour for each folder?
    This should fix your problem :)
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

  • How do you modify the web.xml to lock down the pages from a user role

    how do you modify the web.xml to lock down the pages from a user role

    I'll make a stab at your question:
    The following is an example of where a URL is protected within a web.xml deployment descriptor. In this example, the URL /protectedA within the application is protected:
    <!-- security constraints -->
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>protectedA</web-resource-name>
    <url-pattern>/protectedA</url-pattern>
    </web-resource-collection>
    <!-- authorization -->
    <auth-constraint>
    <role-name>sr_developer</role-name>
    </auth-constraint>
    </security-constraint>
    Sun's explaination here:
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Security4.html

  • Need help to set values from web.xml in a jsp class

    Hey :-)
    I`m trying to get value from my web.xml file into a jsp class. The problem is that the value always retur null. My web.xml file is replaced in the WEB-INF directory where should be. Here is my web.xml
    <servlet>
    <servlet-name>Html</servlet-name>
    <servlet-class>Html</servlet-class>
    <init-param>
    <param-name>html_test</param-name>
    <param-value>Value I want have in my jsp class
    </param-value>
    </init-param>
    </servlet>
    And her i my java class who don`t work:
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import javax.servlet.ServletConfig;
    public class Html extends BodyTagSupport
    String title="";
    String html_test;
    ServletConfig config;
    public void doInitBody() throws JspException
    html_test = config.getInitParameter("html_test");
    }//End of method doInitBody()
    public int doStartTag() throws JspException
    try
    JspWriter out = pageContext.getOut();
    out.print( "<HTML>\n" );
    out.print( "<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" );
    out.print( "<BODY>\n" );
    out.print( "<BR><H1>" + html_test + "</H1>" );
    And here are my html_test variable return null.
    I hope somone can help me, duke dollars will be given away for the solution answer.
    paulsep

    Nothing seems to work, have change the string and rewritten the web.xml file to:
    <?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>
              <context-param>
                   <param-name>html_test</param-name>
                   <param-value>Value I want have in my jsp class</param-value>
              </context-param>
    </web-app>

Maybe you are looking for