Web.xml clarification

Hello,
in a servlet we would like to read web.xml sections which are not accessible through the servlet/context-getParameter methods. So we wrote a utility to get access to these elements. The problem is, that we receive an error, if the parser has no access to the DTD defined in the DOCUMENT section of the web.xml file (which is normal in an intranet).
Error: javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
If we remove the DOCUMENT part then the parser works correctly but the application does not start and we receive
SAXParseException: Element type "web-app" must be declared.
We do not get this error even if there is no access to the Internet!!! How does the application server handle this situation?
Question: What is the usual proceeding
a) make a copy of the DTD file and store it locally?
b) is it possible to switch the validation off (I tried this and failed code below).
Any suggestions and clarifications welcome.
Regards, Rainer
----------------------- code snippet ------------------------
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringComments(true); //No need for comments
factory.setIgnoringElementContentWhitespace(true); //No need for WS
factory.setNamespaceAware(true); //No need for Namespaces
factory.setValidating(false); //No need for DTD ??????? DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse( FileName );

You've added these to a <servlet> element right? And I'm assuming that this isnt' your servlet or you'd have seen them being used in the code.
Basically, they're initialization parameters that are passed to your servlet via the ServletConfig object and which you can access.
For example, you could define your DB URL ( though that would probably be better off as a <context-param> instead ) here, in your web.xml and then use the string in your servlet instead of hardcoding it. This way, changes would be easier.
In your case, you're adding two parameters, debug=3 and detail=3. When you use ServletConfig.getInitParameter("debug") or ServletConfig.getInitParameter("detail"), you'll get values of 3 and 3.

Similar Messages

  • Clarification regarding web.xml

    Hi
    we have written the following steps in web.xml.
    <init-param>
    <param-name>debug</param-name>
    <param-value>3</param-value>
    </init-param>
    <init-param>
    <param-name>detail</param-name>
    <param-value>3</param-value>
    </init-param>
    so, what is the main purpose of these init-params

    You've added these to a <servlet> element right? And I'm assuming that this isnt' your servlet or you'd have seen them being used in the code.
    Basically, they're initialization parameters that are passed to your servlet via the ServletConfig object and which you can access.
    For example, you could define your DB URL ( though that would probably be better off as a <context-param> instead ) here, in your web.xml and then use the string in your servlet instead of hardcoding it. This way, changes would be easier.
    In your case, you're adding two parameters, debug=3 and detail=3. When you use ServletConfig.getInitParameter("debug") or ServletConfig.getInitParameter("detail"), you'll get values of 3 and 3.

  • Confused about jrun-web.xml

    G'day there
    I'm hoping someone can clarify the *actual* purpose of the
    [cf]/WEB-INF/jrun-web.xml file, and how CF uses it.
    My understanding of it was that it was the
    JRun-internal-webserver's
    equivalent of Apache's httpd.conf, or IIS's... err...
    whereever IIS stores
    its config. Basically a web server configuration file. So if
    one wasn't
    actually USING the JRun webserver for a given web site, then
    that file is
    just ignored.
    However that understanding is incorrect, it seems.
    I have this sort of set-up on my dev machine's file system:
    C:\webroots
    \webapp1root
    \lib
    \subapp
    \myCfc.cfc
    \webapp2root
    \lib
    \subapp
    \myCfc.cfc
    And my IIS default website (I'm just running XP Pro, so only
    one website @
    a time) is set up to have either webapp1root or webapp2root
    as its webroot,
    depending on which I am working on, at a given moment in
    time. And the
    website also has a virtual directory to "subapp", called...
    "subapp".
    Currently I'm working on webapp1, so was bemused that when I
    did this:
    createObject("component", "subapp.myCfc")
    I was getting an instance of
    C:\webroots\webapp2root\lib\subapp\myCfc.cfc
    created, instead of the webapp1 version.
    I spent rather too long ballocksing around checking virtual
    directories, CF
    mappings and all that sort of palarver, only to eventualy
    find that I had a
    residual mapping in my jrun-web.xml file pointing to
    webapp2root's subapp
    directory.
    Once I removed that: all good.
    Now to me, jrun-web.xml should be completely irrelevant to
    that mix, as I'm
    not using the JRun web server.
    So obviously it's NOT just a web server config file. WTF *is*
    it?
    I have read various docs on the Adobe website, but they all
    seem to be
    written for an audience who would already know what the
    author is on about
    (hence making the doc a bit of a waste of time, in my view),
    and it's all
    completely impenetrable for me, as I'm just a CF developer
    and haven't got
    a clue about the inner workings of JRun (and, to be frank:
    I'd like to keep
    it that way if poss... JRun knowledge is not exactly a
    marketable skill
    What am I missing here?
    Adam

    I didn't skip over that part, but I probably wasn't as clear
    as I needed to be. web.xml (and jrun-web.xml) are deployment
    descriptors for a J2EE web application. That actually has nothing
    to do with a "web server", it has to do with telling the
    application server (JRun, in this case), any information it needs
    to deploy the web application (ColdFusion, in this case). The
    jrun-web.xml file simply includes stuff that isn't apart of the
    J2EE spec but JRun developers thought it helpful to add in.
    Again, _it has nothing to do with the "web server" as you see
    it_.
    If you are using IIS as your frontend web server, you're
    still using JRun, the Application Server. In order for the JRun
    Application Server (_not_ the web server) to start, it looks at
    certain files to determine what web applications to deploy and how
    to deploy them. Those files are web.xml and jrun-web.xml, among
    others. The reason they're named "web.xml" and "jrun-web.xml" is
    because it's deploying a "J2EE
    Web Application". It has absolutely nothing to do with a web
    server (an application that listens on port 80 or 443 and responds
    to HTTP requests).
    Let's see if I missed anything from your post:
    quote:
    G'day there
    I'm hoping someone can clarify the *actual* purpose of the
    [cf]/WEB-INF/jrun-web.xml file, and how CF uses it.
    My understanding of it was that it was the
    JRun-internal-webserver's
    equivalent of Apache's httpd.conf, or IIS's... err...
    whereever IIS stores
    its config. Basically a web server configuration file. So if
    one wasn't
    actually USING the JRun webserver for a given web site, then
    that file is
    just ignored.
    Nope. It's not a "web server configuration file". It's a web
    application deployment descriptor. Lots different. It all stems
    from the fact that ColdFusion is nothing more than a J2EE web
    application being deployed on JRun.
    quote:
    {snip}
    Now to me, jrun-web.xml should be completely irrelevant to
    that mix, as I'm
    not using the JRun web server.
    So obviously it's NOT just a web server config file. WTF *is*
    it?
    See my first post, and clarification at the top of this post
    quote:
    I have read various docs on the Adobe website, but they all
    seem to be
    written for an audience who would already know what the
    author is on about
    (hence making the doc a bit of a waste of time, in my view),
    and it's all
    completely impenetrable for me, as I'm just a CF developer
    and haven't got
    a clue about the inner workings of JRun (and, to be frank:
    I'd like to keep
    it that way if poss... JRun knowledge is not exactly a
    marketable skill
    What am I missing here?
    I have no idea how that mapping got in there in the first
    place, but this is standard J2EE deployment descriptor stuff. Most
    other J2EE servers (BEA, Glassfish, JBoss, etc) all have a
    server-specific ___-web.xml deployment descriptor that goes along
    with each web app, telling the Application Server the information
    it needs to deploy the web app.
    So, to sum up:
    jrun-web.xml is not a web server configuration file.
    jrun-web.xml is a JRun-specific J2EE Web Application
    deployment descriptor file.
    J2EE Web Application deployment descriptor files have nothing
    to do with a web server (an application that responds to HTTP
    requests), though the web.xml and jrun-web.xml files do tell JRun
    how to interpret the requests passed to it via the IIS ISAPI
    filter.
    I don't know how you got that mapping in there in the first
    place.

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

  • How can I get the context-parm from a web.xml file using struts?

    Hello:
    I need get the context-param from the web.xml file of my web project using struts. I want configurate the jdbc datasource connection pooling here. For example:
    <context-param>
    <param-name>datasource</param-name>
    <param-value>jdbc/formacion</param-value>
    <description>Jdbc datasource</description>
    </context-param>
    and then from any Action class get this parameter.
    Similar using a simple server can be:
    /** Initiates new XServlet */
    public void init(ServletConfig config) throws ServletException {
              for (Enumeration e = config.getInitParameterNames(); e.hasMoreElements();) {
                   System.out.println(e.nextElement());
              super.init(config);
              String str = config.getInitParameter("datasource");
              System.out.println(str);
         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("nada");
              out.flush();
              out.close();
    but only this works for init-params, if I use
    <servlet>
         <servlet-name>MyServlet</servlet-name>
         <display-name>MyServlet</display-name>
         <servlet-class>myExamples.servlet.MyServlet</servlet-class>
         <init-param>
         <param-name>datasource</param-name>
         <param-value>jdbc/formacion</param-value>
    </init-param>
    </servlet>
    inside my web.xml. I need something similar, but using struts inside the action class for that I can get the context-params and call my database.
    Thank you

    To get context parameters from your web.xml file you can simply get the ActionServlet object from an implementing action object class. In the perform (or execute) method make the following call.
    ServletContext context = getServlet().getServletContext();
    String tempContextVar =
    context.getInitParameter("<your context param >");

  • Problem with web.xml, while migratig application from JBOSS 5.0 to JBOSS5.1

    Hi ,
    Earlier my application was running fine on JBOSS 5.0 .
    In that web.xml was like
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"
         id="WebApp_ID" version="2.4">
         <servlet>
              <servlet-name>action</servlet-name>
              <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
              <init-param>
                   <param-name>config</param-name>
                   <param-value>/WEB-INF/struts-config.xml</param-value>
              </init-param>
              <load-on-startup>1</load-on-startup>
         </servlet>
         <!-- Timer Details -->
         <servlet>
              <servlet-name>perfMonCollector</servlet-name>
              <servlet-class>com.dbag.optimise.performancemonitor.timer.PerfMonitorCollector</servlet-class>
              <load-on-startup>4</load-on-startup>
              <init-param>
                   <param-name>cronExpr</param-name>
                   <param-value>0 0 0 */1 * ?</param-value>
                   <!--<param-value>0 */10 * * * ?</param-value> -->
              </init-param>
         </servlet>
         <servlet>
              <servlet-name>TransAnalysisCollector</servlet-name>
              <servlet-class>com.dbag.optimise.performancemonitor.timer.TransAnalysisCollector</servlet-class>
              <load-on-startup>3</load-on-startup>
              <init-param>
                   <param-name>cronExprTransAnalysis</param-name>
                   <param-value>*/30 * * * * ?</param-value>
              </init-param>
         </servlet>
         <!-- Timer Details -->
         <!-- PerfMonPoints Cache Generation on Server Startup -->
         <servlet>
              <servlet-name>perfMonGenerator</servlet-name>
              <servlet-class>com.dbag.optimise.performancemonitor.timer.PerfMonPointsGenerator</servlet-class>
              <load-on-startup>2</load-on-startup>
         </servlet>
         <!-- PerfMonPoints Cache Generation on Server Startup -->
         <!-- Standard Action Servlet Mapping -->
         <servlet-mapping>
              <servlet-name>action</servlet-name>
              <url-pattern>*.do</url-pattern>
         </servlet-mapping>
         <!-- The Usual Welcome File List -->
         <welcome-file-list>
              <welcome-file>jsp/index.jsp</welcome-file>
         </welcome-file-list>
    But now i have deployed my application on JBOSS 5.1 GA version.
    Now its giving exception.
    Caused by:
    org.xml.sax.SAXException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One of '{"http://java.sun.com/xml/ns/javaee":run-as, "http://java.sun.com/xml/ns/javaee":security-role-ref}' is expected. @ vfsfile:/local/dubeavi/jboss-5.1.0.GA/server/default/deploy/PerformanceMonitoringISE-1.0/WEB-INF/web.xml[28,15]
    at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$MetaDataErrorHandler.error(SaxJBossXBParser.java:426)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
    at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:199)
    ... 41 more

    My new web.xml is like..
    <web-app
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         id="WebApp_ID"
         version="2.5">
         <servlet>
              <servlet-name>action</servlet-name>
              <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
              <init-param>
                   <param-name>config</param-name>
                   <param-value>/WEB-INF/struts-config.xml</param-value>
              </init-param>
              <load-on-startup>1</load-on-startup>
         </servlet>

  • How to give relative path in web.xml?

    Hi All,
    Im creating a servlet which has to load the properties file.
    I don't want to give the location of the properties file as ABSOLUTE PATH. But I'm unable to provide the same as RELATIVE PATH.
    When I give the path is given as ABSOLUTE PATH (drive:/dir/) it is working. But if I give the RELATIVE PATH(../), the same is not working.
    Kindly help me in this.
    Regards,
    Kumar Madhavan.
    My web.xml file is:
    <?xml version="1.0"?>
    <!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>
         <display-name>NGT - ASCII</display-name>
         <description>Application for Safety Critical Information vIew.</description>
         <welcome-file-list>
              <welcome-file>ASCII.html</welcome-file>
         </welcome-file-list>
         <context-param>
              <param-name>asciifiledir</param-name>
    <!-- This is the tag in which I would like to
              <param-value>../</param-value>
         </context-param>
    </web-app

    Hi.
    Exclude the directory path from the <param-value/> in
    the web.xml and just keep the property file name.
    Place the property file in the classpath and load it
    like this from the servlet:
    Properties props = new Properties();
    String propFileName = "" // Read param-value from web.xml
    try {
    InputStream is = TheServlet.class.getResourceAsStream(propFileName);
    props.load(is);
    } catch (Exception ex) {
    System.out.println("Prop file not in classpath!");
    /Jesper

  • How to use dynamic file as welcome-file-list in web.xml

    I have configured my web.xml file as this,
    <web-app>
    <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
    </context-param>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
    <welcome-file>login.jsf</welcome-file>
    </welcome-file-list>
    </web-app>
    and my login.xhtml file as this,
    <!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"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:c="http://java.sun.com/jstl/core"
    xmlns:f="http://java.sun.com/jsf/core">
    <body>
    <f:view>
    <h:form>
    UserName:<h:inputText id="userName"
    value="#{bean.userName}" rendered="true"
    required="true"/>
    Password:<h:inputText id="password"
    value="#{bean.password}" rendered="true"
    required="true"/>
    <h:commandButton id="submit" value="Submit" action="#{bean.authenticate}" />
    </h:form>
    </f:view>
    </body>
    </html>
    but when i deploy this using tomcat and try to put url as this,
    http://localhost:8080/project
    Its not identifying welcome file from web.xml
    I am getting error like this,
    The requested resource (/project/) is not available.
    How to resolve this,
    Thanks,
    Vinutha

    This might help:
    http://forum.java.sun.com/thread.jspa?threadID=696586
    As well, you might have to change the servlet-mapping in your web.xml. The url-pattern, I think, needs to be .xhtml. Your login.jsf file in the welcome list will need to be renamed to login.xhtml.
    CowKing

  • Replacing web.xml values with a deployment plan.  Not working on WL 10.3.2

    Hi All-
    I am trying to replace a value from web.xml with one in a weblogic deployment plan. I deployed the application on WL 10.3.2 and used the deployment plan below. No matter what I do it doesn't seem to want to take the value.
    web.xml:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!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>TokenGroup</param-name>
    <param-value>oldvalue</param-value>
    </context-param>
    </web-app>
    Deployment Plan:
    <?xml version='1.0' encoding='UTF-8'?>
    <deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd"
    global-variables="false">
    <application-name>APPName</application-name>
    <variable-definition>
    <variable>
    <name>TokenGroup</name>
    <value>Key123456</value>
    </variable>
    </variable-definition>
    <module-override>
    <module-name>APPName.war</module-name>
    <module-type>war</module-type>
    <module-descriptor external="false">
    <root-element>web-app</root-element>
    <uri>WEB-INF/web.xml</uri>
    <variable-assignment>
    <name>TokenGroup</name>
    <xpath>/web-app/context-param/[param-name="TokenGroup"]/param-value</xpath>
    <operation>replace</operation>
    </variable-assignment>
    </module-descriptor>
    </module-override>
    </deployment-plan>
    I've also tried other formats for the xpath such as:
    /web-app/context-param/{param-name="TokenGroup"}/param-value
    /web-app/context-param[param-name="TokenGroup"]/param-value
    Any ideas why this doesnt work?
    Thanks,
    Joe

    "web.xml"
    <?xml version='1.0' encoding='WINDOWS-1252'?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <context-param>
    <param-name>name</param-name>
    <param-value>Joe</param-value>
    </context-param>
    <context-param>
    <param-name>password</param-name>
    <param-value>password</param-value>
    </context-param>
    <servlet>
    <servlet-name>ParameterServlet</servlet-name>
    <servlet-class>ParameterServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ParameterServlet</servlet-name>
    <url-pattern>/ParameterServlet</url-pattern>
    </servlet-mapping>
    </web-app>
    ParameterServlet
    import java.io.IOException;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletException;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class ParameterServlet extends HttpServlet {
    private String dbName = "";
    private String dbPassword = "";
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    ServletContext context = getServletContext();
    dbName = context.getInitParameter("name");
    dbPassword = context.getInitParameter("password");
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws IOException {
    ServletOutputStream out = res.getOutputStream();
    res.setContentType("text/html");
    out.println("<html><head><title>Basic Servlet</title></head>");
    out.println("<body>Database username is <b>" + dbName);
    out.println("</b><br>Database password is <b>" + dbPassword + "</b>");
    out.println("</body></html>");
    "Plan.xml"
    <?xml version='1.0' encoding='UTF-8'?>
    <deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd" global-variables="false">
    <application-name>virtual</application-name>
    <variable-definition>
    <variable>
         <name>name</name>
         <value>akshay1</value>
         </variable>
         <variable>
         <name>password</name>
         <value>koul1</value>
         </variable>
    </variable-definition>
    <module-override>
    <module-name>virtual</module-name>
    <module-type>war</module-type>
    <module-descriptor external="false">
    <root-element>web-app</root-element>
    <uri>WEB-INF/web.xml</uri>
         <variable-assignment>
              <name>name</name>
              <xpath>/web-app/context-param/[param-name="name"]/param-value</xpath>
              <operation>replace</operation>
         </variable-assignment>
         <variable-assignment>
              <name>password</name>
              <xpath>/web-app/context-param/[param-name="password"]/param-value</xpath>
              <operation>replace</operation>
         </variable-assignment>
    </module-descriptor>
    </module-override>
    <config-root>C:\DOCUME~1\user\LOCALS~1\Temp\user\.\config\deployments\virtual\plan</config-root>
    </deployment-plan>
    It works for me... I think your "web.xml" is causing the issue.
    Try replacing
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!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>
    with
    <?xml version='1.0' encoding='WINDOWS-1252'?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    Hope this helps.
    -Akshay

  • Web.xml mapping not working

    I have a servlet located at com.conversion.web called leftNavReader.java
    I'm trying to access this servlet on my localhost with the following URL: http://localhost:8080/Conversion/start
    but I keep getting this error:
    HTTP Status 404 - /Conversion/start
    type Status report
    message /Conversion/start
    description The requested resource (/Conversion/start) is not available.
    Here is what my web.xml looks like:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app>
         <display-name>DataConversionWeb</display-name>
         <servlet>
              <servlet-name>start</servlet-name>
              <display-name>Start</display-name>
              <servlet-class>com.conversion.web.leftNavReader</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>start</servlet-name>
              <url-pattern>/start</url-pattern>
         </servlet-mapping>
    </web-app>
    Does anyone have any idea why I'm getting this error?

    Since the spaces may cause problems and I have
    everything in the My Projects directory, I decide to
    just start from scratch. Very good.
    But... someone else
    installed eclipse for me and set that up, so I may
    need some help with that, not sure if you can help.As far as I know Eclipse can also be Unzipped to any folder, and
    theres a file called eclipse.exe , one would simply double click on that to invoke eclipse. I don't think you would have to re-install Eclipse.
    You could create a new project, and set
    C:\dev\projects\Conversion\ as your Eclipse Workspace .
    But lets put Eclipse on hold for now, we can still configure this whole project manually without Eclipse, which will help you understand what's going on under the hood. Also, in the beginning it's simpler to configure independent of the IDE.
    So I recommend that you save your work, uninstall
    Tomcat 6.0.x and re-install it on a path thatdoesn't
    have any spaces in it.
    For example:
    C:\dev\tomcat\ So I've uninstalled tomcat and re-installed in
    c:\dev\tomcat as recommended...Good, I assume that immediately under C:\dev\tomcat\ folder you see folders like bin, conf, webapps etc
    Assuming that Tomcat was Unzipped to the above
    folder. and there isn't another main folder underthe
    above folder, set you system envrionment variable
    CATALINA_HOME to the above folder.How do I do this?On MS Windows, click Start ---> Settings ----> Control Panel
    Look for System , --> Doubl Click on System -----> Click on the Advanced tab ----> then under the "System Variables" panel ------> Click on New button -------->
    in the Variable Name: type CATALINA_HOME
    in the Variable Value: type C:\dev\tomcat
    Then click Ok , that will set CATALINA_HOME to C:\dev\tomcat
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    There's a RUNNING.txt file under Tomcat's folderthat
    explains configuring it. Tomcat expects JAVA_HOMEto
    be set to your JDK's root folder . Again if JDK is
    installed on a path that has spaces then Irecommend
    installing it on a path with no spaces forexample:
    C:\dev\jdk\
    Similarly , follow the above steps to set JAVA_HOME to C:\dev\jdk
    Also, under System Variables you may see a variable called Path
    If it doesn't exist , then create a new one, if it already exists then add the following to the Path variable. (notice how the semi colon is used as a separater)
    ;%JAVA_HOME%/bin;%CATALINA_HOME%/bin;
    By setting the above you will be able to call
    java , javac and Tomcat's startup.bat and shutdown.bat from anywhere on the DOS Command line.
    >>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~I've moved the jdk to the director as recommended,
    but not sure hot to set the JAVA_HOME.See above...
    I haven't even gotten through the rest of your post
    yet, as I need to work on getting Eclipse set up
    again too Leave Eclipse for later ---- it will just complicate things for now.
    Once you have the project runnun under Tomcat we can figure out Eclipse.
    and I figure I might as well set up my
    "new" project using Virtual Hosts from the beginningLeave Virtual Host for later ------ it is easy to understand , I will explain it later , once you have the above basic set up running.
    and do this right... This is quite the learning
    experience ;)First , second and third time it is... but if you do this often, it will get much easier.

  • Client-cert auth impl in web.xml does not work in Oracle Application Server

    Hi,
    I am new to implementing security features on the web applications.. I have developed a new web service using jdev1012 and deployed in OAS 10.1.2. Its working fine according to the business requirements, but I am in need of implementing client-cert authentication to enable the web service available to only those who have client certificate.
    My server details are:
    Oracle Application Server 10g Release 2 (10.1.2)
    Server certificate is in place and SSL mode have been already enabled.. able to access my web service through https://<mydomain.com>/myws/TreqWS as well able to see the WSDL file through https://<mydomain.com>/myws/TreqWS?WSDL.
    I tried to include the following in my web.xml file as part of implementing CLIENT-CERT authentication.
    <security-constraint>
    <display-name>SecurityConstraint</display-name>
    <web-resource-collection>
    <web-resource-name>WSCollection</web-resource-name>
    <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
    <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
    </security-constraint>
    <login-config>
    <auth-method>CLIENT-CERT</auth-method>
    <realm-name>WSCollection</realm-name> <!-- am not sure about this realm-name and its purpose -->
    </login-config>
    It is not woking as expected, though I have restarted my oc4j container after including this content to the web.xml file. i.e, I am able to invoke the web service though my sample java client program, though I donot have client certificate/keystore.
    I believe I am missing something..Can anyone help me in this regard to implement CLIENT-CERT authentication successfully?
    Thanks,
    Ms

    I am having the same problem with doc and xsl. I have added this
    <mime-mapping>
    <extension>xls</extension>
    <mime-type>application/vnd.ms-excel</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>doc</extension>
    <mime-type>application/msword</mime-type>
    </mime-mapping>
    to my web.xml. I even restarted the server. I still see doc and xsl in binary.
    Is there some other setting that needs to take place?
    I am using WL6.1 with fixpack 1.
    I can see the doc and excel files in the browser if I don't go through the weblogic
    server. That just confirms it's not my browser.
    Kumar Allamraju <[email protected]> wrote:
    <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
    <html>
    It works fine for me in 6.1 SP1.
    <br><br>
    If the following doesn't work , can you
    <br>try application/winword instead of application/msword?
    <p>--
    <br>Kumar
    <p>Siming Mu wrote:
    <blockquote TYPE=CITE>Hi,
    <p>I setup in my web.xml a mime mapping as follows,
    <p><mime-mapping>
    <br><extension>doc</extension><mime-type>application/msword</mime-type>
    <br></mime-mapping>
    <p>When I specify a test.doc url, the doc file appears in my browser
    as
    binary data
    <br>instead of download.
    <p>Please reference change request 055002, which decribes this problem. 
    According
    <br>to edocs, it has been fixed in wls6.1sp1.
    <p>But I am seeing it fixed.  Am I doing anything wrong? Thanks.
    <p>Siming</blockquote>
    </html>

  • Unable to load descriptor .../web.xml - DescriptorException - Java EE6 war

    Deploying a simple Java EE 6 war into WebLogic 10.3.3 fails with <Unable to load descriptor /root/Oracle/Middleware/user_projects/domains/palis1/servers/AdminServer/upload/SimpleEE6App.war/WEB-INF/web.xml of module SimpleEE6App.war. The error is weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
    problem: cvc-enumeration-valid: string value '3.0' is not a valid enumeration value for web-app-versionType in namespace http://java.sun.com/xml/ns/javaee:<null>
    The web app consists of one JSF 2 web dialog, one managed bean, one stateless session bean and one entity bean. In GlassFish v3 the app works fine. Then I installed the actual version of WebLogic server in order to check whether I can run EE6 apps there to. But deploying the war using WebLogic admin console fails with
    ... <AdminServer> <main> <<WLS Kernel>> <> <> <1273649525966> <BEA-000360> <Server started in RUNNING mode>
    ... <AdminServer> <[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'> <admin> <> <> <1273649790693> <BEA-160197> <Unable to load descriptor /root/Oracle/Middleware/user_projects/domains/palis1/servers/AdminServer/upload/SimpleEE6App.war/WEB-INF/web.xml of module SimpleEE6App.war. The error is weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
    problem: cvc-enumeration-valid: string value '3.0' is not a valid enumeration value for web-app-versionType in namespace http://java.sun.com/xml/ns/javaee:<null>
    at weblogic.descriptor.internal.MarshallerFactory$1.evaluateResults(MarshallerFactory.java:245)
    at weblogic.descriptor.internal.MarshallerFactory$1.evaluateResults(MarshallerFactory.java:231)
    at weblogic.descriptor.internal.MarshallerFactory$1.createDescriptor(MarshallerFactory.java:155)
    at weblogic.descriptor.BasicDescriptorManager.createDescriptor(BasicDescriptorManager.java:323)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.getDescriptorBeanFromReader(AbstractDescriptorLoader2.java:788)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.createDescriptorBean(AbstractDescriptorLoader2.java:409)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBeanWithoutPlan(AbstractDescriptorLoader2.java:759)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBean(AbstractDescriptorLoader2.java:768)
    at weblogic.servlet.internal.WebAppDescriptor.getWebAppBean(WebAppDescriptor.java:141)
    at weblogic.servlet.utils.WarUtils.getWebAppBean(WarUtils.java:124)
    at weblogic.application.compiler.WARModule.processLibraries(WARModule.java:413)
    at weblogic.application.compiler.WARModule.merge(WARModule.java:455)
    at weblogic.application.compiler.flow.SingleModuleMergeFlow.proecessModule(SingleModuleMergeFlow.java:16)
    at weblogic.application.compiler.flow.SingleModuleFlow.compile(SingleModuleFlow.java:36)
    at weblogic.application.compiler.FlowDriver$FlowStateChange.next(FlowDriver.java:69)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
    at weblogic.application.compiler.FlowDriver.nextState(FlowDriver.java:36)
    at weblogic.application.compiler.FlowDriver$CompilerFlowDriver.compile(FlowDriver.java:96)
    at weblogic.application.compiler.ReadOnlyWarMerger.merge(ReadOnlyWarMerger.java:27)
    at weblogic.application.compiler.flow.AppMergerFlow.mergeInput(AppMergerFlow.java:88)
    at weblogic.application.compiler.flow.AppMergerFlow.compile(AppMergerFlow.java:41)
    at weblogic.application.compiler.FlowDriver$FlowStateChange.next(FlowDriver.java:69)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
    at weblogic.application.compiler.FlowDriver.nextState(FlowDriver.java:36)
    at weblogic.application.compiler.FlowDriver$CompilerFlowDriver.compile(FlowDriver.java:96)
    at weblogic.application.compiler.AppMerge.runBody(AppMerge.java:157)
    at weblogic.utils.compiler.Tool.run(Tool.java:158)
    at weblogic.utils.compiler.Tool.run(Tool.java:115)
    at weblogic.application.compiler.AppMerge.merge(AppMerge.java:169)
    at weblogic.deploy.api.internal.utils.AppMerger.merge(AppMerger.java:88)
    at weblogic.deploy.api.internal.utils.AppMerger.getMergedApp(AppMerger.java:63)
    at weblogic.deploy.api.model.internal.WebLogicDeployableObjectFactoryImpl.createDeployableObject(WebLogicDeployableObjectFactoryImpl.java:181)
    at weblogic.deploy.api.model.internal.WebLogicDeployableObjectFactoryImpl.createLazyDeployableObject(WebLogicDeployableObjectFactoryImpl.java:156)
    at weblogic.deploy.api.tools.SessionHelper.inspect(SessionHelper.java:661)
    at com.bea.console.actions.app.install.Flow$2.execute(Flow.java:469)
    at com.bea.console.utils.DeploymentUtils.runDeploymentAction(DeploymentUtils.java:5000)
    at com.bea.console.actions.app.install.Flow.appSelected(Flow.java:467)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.beehive.netui.pageflow.FlowController.invokeActionMethod(FlowController.java:870)
    at org.apache.beehive.netui.pageflow.FlowController.getActionMethodForward(FlowController.java:809)
    at org.apache.beehive.netui.pageflow.FlowController.internalExecute(FlowController.java:478)
    at org.apache.beehive.netui.pageflow.PageFlowController.internalExecute(PageFlowController.java:306)
    at org.apache.beehive.netui.pageflow.FlowController.execute(FlowController.java:336)
    The web.xml is
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
    </context-param>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
    <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
    </web-app>
    After changing the version number I got the same error message with the differing number. I also tryed to deploy the web-app_3_0.xsd into the server. This also did not solve the problem.
    Any ideas?
    Thanks in advance
    Axel Burghof

    The web app consists of one JSF 2 web dialog, one managed bean, one stateless session bean and one entity bean. In GlassFish v3 the app works fine. Then I installed the actual version of WebLogic server in order to check whether I can run EE6 apps there to. But deploying the war using WebLogic admin console fails with ...
    Hey Axel -
    WLS 10.3.x does not implement Java EE 6 -- it's a Java EE 5 based server.
    While we have added support for a few independent Java EE 6 specifications where we can -- such as JSF 2.0 in WLS 10.3.3 and JPA 2.0/JAX-RS 1.1 with WLS 10.3.4 that is coming in the next patchset -- we don't support all of the Java EE 6 model and thus you can't use any of the EJB 3.1, Servlet 3.0 changes and you can't deploy EJBs (and JPA entities) inside of a WAR file. Our next major release will be a Java EE 6 implementation, where this will be possible.
    -steve-

Maybe you are looking for