Use of jsp-file in web.xml

hello
can anybody explain about , when we need <jsp-file> in web.xml
and why we use this tag in place of <url-pattern>?

If you want to declare a JSP in your web.xml file you use the jsp-file tag instead of the servlet-class tag. Normally there is no need to declare a JSP in the web.xml file unless you want to use init-params.
Usually people can access a JSP directly wether it is declared in the web.xml or not. So it is not that the jsp-file tag replaces the url-pattern tag so much as the url-pattern tag is not needed for a JSP. However notthing prevents you from declaring the JSP in the web.xml and then mapping the JSP to a different url that doesn't end in '.jsp'.

Similar Messages

  • Cannot find JSP file through web.xml

    Content of a.jsp
    function Thisthing (id, name) {
    this.id = id;
    this.descr = name;
    I want to access a.jsp from b.jsp. like
    <script type="text/javascript" src="a.js"></script>
    I have web.xml content
    <servlet>
    <servlet-name>DomainObjectis</servlet-name>
    <jsp-file>/a.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
    <servlet-name>DomainObjectis</servlet-name>
    <url-pattern>*.js</url-pattern>
    </servlet-mapping>
    However its showing me an error -> .Thisthing undefined whenever I run this in Tomcat 5.5.
    I appears its not finding my a.jsp file. It's working fine when I do
    <%@ include file="a.jsp" %>

    thanks for replying jgalacambra.
    I have deployed several web applications before. But this is the first one where I am trying to include a JSP file as a javascript.
    tomcat recognizes when I simply including the jsp file with import but when I try to include it as a script it's not working. So I am hoping that there are some experts here who can help me. I saw this being done in a project and am trying to build a similar web application myself.

  • How to chage the welcome file in web.xml using creator?

    Hi guys,
    I want to set the welcome file in web.xml to index.html but every time I run my project in creator, creator replaces index.html by faces/index.jsp. I need the index.html to check if the browser enables cookies & javascript and then I redirect to index.jsp. If I change the web.xml in a common editor, build the war-file with ant and deploy the project with tomcat, everything is fine. but how can I change it in creator?
    thanks in advance

    Sorry, that doesn't make much sense.
    The XML you gave is a configuration file for txt2xml utility. It doesn't represent the output format.
    Are you a user of this utility?

  • Include another xml file in web.xml

    I was able to use XML Entity to include another xml file in web.xml for older servlet specifications, i.e.:
    <?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" [
      <!ENTITY my-web SYSTEM "my-web.xml">
    ]>
    <web-app>
      &my-web;
    </web-app>This allows me to share my-web.xml among various web applications.
    How do I achieve the same thing for servlet specification 2.5, which does not have a DTD but rather an XSD?
    <?xml version="1.0" encoding="UTF-8"?>
    <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">I am using Glassfish V2UR1. I know about $domain-dir/config/default-web.xml, but for reasons I won't get into I cannot put things in there.

    Hi Maksim. I understood that. It's just that I would prefer some method that doesn't require the developers to do something like extracting a file from the EAR file, changing the file and then putting it back in. As you probably know, some developers could handle it and some will most certainly make mistakes.
    When they do they come to my group and say "my app doesn't work" and then we have to spend time figuring out why.
    Plus, once the developers get used to doing things the automated way they're going to have a hard time remembering to do a manual step each time they do a build.
    I have heard that there may be some way to do something similar to this on Visual Administrator. I'm going to investigate that too.
    Thanks!
    David.

  • Java property file in web.xml?

    I'm having trouble getting a web app to work resonably closely to how I expect:
    I have a property file that is accessed by the package of java classes ( under
    WEB-INF/classes). In the classes ( package com.th.lifeinsruance ) i have a property
    file which is referenced in the java code as com.th.lifeinsurance.xx.properties.
    It seems the only place that wl6.0 is prepared to look for this property file
    is under the /weblogic6.0 dir ( i.e totally outside the web app!!). I would guess
    that I'm supposed to register this property file in web.xml for the app however
    the only examples refer to DataSources and so on ( to set a resource). Is this
    correct? Does someone have an example of a java property file being read correctly
    in its package with the .class files?
    Many Thanks
    Mark

    I've some other solution for the same problem which is working fine for me.
    1) make a jar file only consisting of the properties file
    jar -cvf DescriptionBundle.jar  DescriptionBundle.properties
    2) copy the jar file to the /dist/Portal-inf/lib folder
    3) Use the following code to get the ResourceBundle
    Locale locale = null;
    Locale locale = null;
    locale = Locale.US;
    servletReq.getSession().setAttribute("myLocale", locale);
    ResourceBundle bundle = ResourceBundle.getBundle("DescriptionBundle", locale);
    if (bundle == null) {
         logger.warning("bundle is null");
    for (Enumeration e = bundle.getKeys(); e.hasMoreElements();) {
         String key = (String) e.nextElement();
         String s = bundle.getString(key);
         servletReq.getSession().setAttribute(key, s);
         logger.info("Key is" + key + "value is" + s);
    This solution doesn't suit  the title of the topic but is another way to access the properties files.

  • Using a .JSP file for the webservice

    Hello,
    I am using a .JSP file to view my webservice, just like in this tutorial: http://otn.oracle.com/tech/webservices/htdocs/series/news/content.html
    But when I try to run my JSP file i get this error:
    500 Internal Server Error
    OracleJSP:
    JSP Error:
    Request URI:/InternAdressen-InternAdresProj-context-root/internadres.jsp
    Exception:
    java.lang.NoClassDefFoundError: _InternAdres
         java.lang.Class java.lang.ClassLoader.defineClass0(java.lang.String, byte[], int, int, java.security.ProtectionDomain)
              native code
         java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String, byte[], int, int, java.security.ProtectionDomain)
              ClassLoader.java:493
    and a lot more of errors like this. Can you help me?

    It didn't work. I still get this error:
    500 Internal Server Error
    OracleJSP:
    JSP Error:
    Request URI:/InternAdressen-InternAdresProj-context-root/internadres.jsp
    Exception:
    java.lang.NoClassDefFoundError: _InternAdres
         java.lang.Class java.lang.ClassLoader.defineClass0(java.lang.String, byte[], int, int, java.security.ProtectionDomain)
              native code
         java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String, byte[], int, int, java.security.ProtectionDomain)
              ClassLoader.java:493
         java.lang.Class java.security.SecureClassLoader.defineClass(java.lang.String, byte[], int, int, java.security.CodeSource)
              SecureClassLoader.java:111
         java.lang.Class oracle.jsp.app.JspClassLoader.loadClass(java.lang.String, boolean)
              JspClassLoader.java:682
         java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String)
              ClassLoader.java:255
         oracle.jsp.runtimev2.JspPageInstFacade oracle.jsp.runtimev2.JspPageInfo.getInstFacade(oracle.jsp.provider.JspClassProvider, javax.servlet.http.HttpServletRequest)
              JspPageInfo.java:160
         oracle.jsp.runtimev2.JspPageInstFacade oracle.jsp.runtimev2.JspPageTable.getInstFacade(javax.servlet.htt[i]Long postings are being truncated to ~1 kB at this time.

  • Which folder i have to put my .jsp file for web report?

    for web report(not the paper report) i put my .jsp files in the
    \reports\j2ee\reports_ids\web
    folder
    this is for the DS(Developer Suite)
    i'm trying to move this file to different machine where AS(Application Server)
    is installed.
    but couldn't find above path. where do i have to put .jsp file for
    web report?
    or do i have to modify in the registry? if so, where?
    Thanks

    Hello,
    Take a look to the thread :
    where to add new jsp reports directory location in path
    "...You have to keep jsp files under document root that is OH/j2ee/OC4J_BI_Forms/applications/reports/web directory. You can create sufbolders under this directory and keep jsp files. ..."
    Regards

  • URL Mapping for packaged JSP's in web.xml file

              Hi,
              I am using weblogic6.0sp2 enterprise edition.I have my JSP's in package structure.
              Suppose my login.jsp is in package com.advice.document. So for URL mapping in
              web.xml what should be given so that by giving that my JSP runs. I have tried
              many options but not got success.
              Here is my web.xml file..
              <web-app>
              <servlet>
              <servlet-name> Login </servlet-name>
              <jsp-file> com\advice\document\login.jsp</jsp-file>
              </servlet>
              <servlet-mapping>
              <servlet-name> Login </servlet-name>
              <url-pattern> /Login</url-pattern>
              </servlet-mapping>
              </web-app>
              If any body knows or have worked on the same then let me know.
              Thanks in advance.
              --- Vipul
              

    Did you try specifying the jsp-file with forward slashes (e.g.,
              com/advice/document/login.jsp)?
              Vipul Garg wrote:
              > Hi,
              > I am using weblogic6.0sp2 enterprise edition.I have my JSP's in package structure.
              > Suppose my login.jsp is in package com.advice.document. So for URL mapping in
              > web.xml what should be given so that by giving that my JSP runs. I have tried
              > many options but not got success.
              > Here is my web.xml file..
              > <web-app>
              > <servlet>
              > <servlet-name> Login </servlet-name>
              > <jsp-file> com\advice\document\login.jsp</jsp-file>
              > </servlet>
              > <servlet-mapping>
              > <servlet-name> Login </servlet-name>
              > <url-pattern> /Login</url-pattern>
              > </servlet-mapping>
              > </web-app>
              >
              > If any body knows or have worked on the same then let me know.
              > Thanks in advance.
              > --- Vipul
              

  • How to read configuration data from an xml file (not web.xml)?

    Hi,
    I want to separate the application specific configuration parameters in a separate xml file and read them as and when they are needed? I know that I can use the wb.xml but I want to separate them in a different xml file because I don't want the web.xml file to be played around later after deployment. If any change is needed then it should be done in the application-config.xml.
    How can I read the parameters from this xml file in my jsp code and also what should be the location of this file if I have
    ../webapps/Root/application
    directoty structure ?
    Any help is greatly appreciated.

    can you give an example of a property file and also
    it is loaded in the jsp ?Hmm... loading properties in a JSP is not a very good idea. You should do it in a separate class, rather than mixing the logic with the display logic.
    Properties properties = new Properties();
    properties.load(UtilClass.class.getResourceAsStream("config.properties"));
    // Add a try - catch block around the load
    // for IOException...

  • How to set an 'alias' for a JSP page in web.xml

    Hi
    Suppose I have a JSP page called SimplePage.jsp and I want to refer to it by someother name while running the application how do I do this in the web.xml file. I have used <servlet-mapping> to do this in the case of a servlet. However I am not sure how to do this with a JSP
    Could somebody show me how to do this. I would be very much grateful.
    All help appreciated and acknowledged.
    thanks in advance
    ilango

    It worked. The correct web.xml version is as below:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app SYSTEM "http://java.sun.com/dtd/web-app_2_3.dtd" [
    ]>
    <web-app>
    <!-- Define servlets that are included in the example application -->
    <servlet>
    <servlet-name>ControllerServlet</servlet-name>
    <servlet-class>ControllerServlet</servlet-class>
    <init-param>
    <param-name>base</param-name>
    <param-value>http://localhost:8080/MVCIIapp/servlet/ControllerServlet</param-value>
    </init-param>
    <init-param>
    <param-name>jdbcDriver</param-name>
    <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
    </init-param>
    <init-param>
    <param-name>imageUrl</param-name>
    <param-value>http://localhost:8080/MVCIIapp/images/</param-value>
    </init-param>
    <init-param>
    <param-name>dbUrl</param-name>
    <param-value>jdbc:odbc:Burnaby</param-value>
    </init-param>
    <init-param>
    <param-name>ilangocal</param-name>
    <param-value/>
    </init-param>
    <init-param>
    <param-name>mangla</param-name>
    <param-value/>
    </init-param>
    </servlet>
    <servlet>
    <servlet-name>Header</servlet-name>
    <jsp-file>/MVCIIapp/jsp/Header.jsp</jsp-file>
    </servlet>     
    <servlet-mapping>
    <servlet-name>ControllerServlet</servlet-name>
    <url-pattern>/Master</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>Header</servlet-name>
    <url-pattern>/Opener</url-pattern>
    </servlet-mapping>     
    </web-app>
    I have other jps files too.I am going to try and put aliases for them and see how they perform.
    I hope I have not spoken too soon by saying that the aliases work. Let me wait and watch with bated breath.
    But thanks a lot for your suggestions without which this would not have been possible
    ilango

  • Welcome File in Web.xml

              I am having problems with my web.xml file.
              I have my welcome page <welcome-file> as my “home_page.jsp” which I want to be
              the default page on start-up. On this page is a link to “log on”. When you click
              on this you are taken to my (FORM) “Login.jsp”. After successful logon I want
              to go to the “Welcome.jsp”, instead I am returned to my “home_page.jsp”. Which
              puts me in a continuous loop. How after successful logon can I be directed to
              a page other than the <welcome-file> “home_page.jsp”
              My web.xml file looks like this;
              <!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>
              <welcome-file-list>
              <welcome-file>Welcome.jsp</welcome-file>
              </welcome-file-list>
              <login-config>
              <auth-method>FORM</auth-method>
              <realm-name>default</realm-name>
              <form-login-config>
                   <form-login-page>/Login.jsp</form-login-page>
                   <form-error-page>/LoginFailure.jsp</form-error-page>
              </form-login-config>
              </login-config>
              <security-role>
              <role-name>web-user</role-name>
              </security-role>
              <security-constraint>
              <web-resource-collection>
              <web-resource-name>Logged into NOTiFY</web-resource-name>
              <url-pattern>/Welcome.jsp</url-pattern>
              <http-method>GET</http-method>
              <http-method>POST</http-method>
              </web-resource-collection>
              <auth-constraint>
              <role-name>web-user</role-name>
              </auth-constraint>
              </security-constraint>
              </web-app>
              Thanks.
              

    It doesn't quite work that way. You should just direct the user directly to
              the Welcome.jsp page. If they're not already logged in, they'll be asked to
              log-in via the Login.jsp. The login mechanism knows to redirect them to the
              last page they wanted once they successfully log in. I think this is why you
              are being returned to the home_page.jsp, since there was no target
              restricted page requested.
              I have to admit - this mechanism doesn't lend itself to the portal-style
              login used on the web. It's geared more towards security and authorization
              for access to particular URL resources. You might need to tweak how your GUI
              looks to make this mechanism make sense.
              Alternatively, you could add some code to the home_page.jsp to redirect the
              user to a specific restricted page based on what is in their session. I
              would also suggest that the Welcome.jsp and home_page.jsp be the same page
              that just behaves differently based upon whether a user is logged in or not.
              "Roger Lee" <[email protected]> wrote in message
              news:[email protected]...
              >
              > I am having problems with my web.xml file.
              >
              > I have my welcome page <welcome-file> as my "home_page.jsp" which I want
              to be
              > the default page on start-up. On this page is a link to "log on". When you
              click
              > on this you are taken to my (FORM) "Login.jsp". After successful logon I
              want
              > to go to the "Welcome.jsp", instead I am returned to my "home_page.jsp".
              Which
              > puts me in a continuous loop. How after successful logon can I be directed
              to
              > a page other than the <welcome-file> "home_page.jsp"
              >
              > My web.xml file looks like this;
              >
              > <!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>
              >
              > <welcome-file-list>
              > <welcome-file>Welcome.jsp</welcome-file>
              > </welcome-file-list>
              >
              > <login-config>
              > <auth-method>FORM</auth-method>
              > <realm-name>default</realm-name>
              > <form-login-config>
              > <form-login-page>/Login.jsp</form-login-page>
              > <form-error-page>/LoginFailure.jsp</form-error-page>
              > </form-login-config>
              > </login-config>
              >
              > <security-role>
              > <role-name>web-user</role-name>
              > </security-role>
              >
              > <security-constraint>
              > <web-resource-collection>
              > <web-resource-name>Logged into NOTiFY</web-resource-name>
              > <url-pattern>/Welcome.jsp</url-pattern>
              > <http-method>GET</http-method>
              > <http-method>POST</http-method>
              > </web-resource-collection>
              > <auth-constraint>
              > <role-name>web-user</role-name>
              > </auth-constraint>
              > </security-constraint>
              >
              > </web-app>
              >
              > Thanks.
              >
              

  • (newbie) Question about replacing .class files and web.xml file

    I'm new to servlets and I have two quick questions...
    Do I absolutely need a web.xml file to define all my servlets, or can I simply place .class files into the WEB-INF directory and expect them to run?
    If my application server (for example Tomcat) is running and I replace a servlet .class file, do I need to restart the server for the new .class file to take effect?
    ...or are both of these questions specific to the application server I'm using?

    Hi,
    From an article I read:
    With Tomcat 3.x, by default servlet container was set up to allow invoking a servet through a common mapping under the /servlet/ directory.
    A servlet could be accessed by simply using an url like this one:
    http://[domain]:[port]/[context]/servlet/[servlet full qualified name].
    The mapping was set inside the web application descriptor (web.xml), located under $TOMCAT_HOME/conf.
    With Tomcat 4.x the Jakarta developers have decided to stop allowing this by default. The <servlet-mapping> tag that sets this mapping up, has been commented inside the default web application descriptor (web.xml), located under $CATALINA_HOME/conf:
    <!-- The mapping for the invoker servlet -->
    <!--
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
    -->
    A developer can simply map all the servlet inside the web application descriptor of its own web application (that is highly suggested), or simply uncomment that mapping (that is highly discouraged).
    It is important to notice that the /servlet/ isn't part of Servlet 2.3 specifications so there are no guarantee that the container will support that. So, if the developer decides to uncomment that mapping, the application will loose portabiliy.
    And declangallagher, I will use caution in future :-)

  • Do I have to register all *.jsp servlets in web.xml?

    All,
    I'm hoping someone in this forum can help me. I'm working on a report generator that uses JSP to generate a template which is fed to a formatter. What I want is to programatically call the JSP without having to add an entry for every single report to my web.xml. As you can imagine this doesn't scale well since every time a new type of report is added, someone has to go edit the web.xml.
    The options I can think of:
    1) Pre-compile the JSP's
    2) Have a servlet mapping where *.jsp "does the right thing" for me
    3) ?
    Any suggestions? I'm not sure which is the best/practical approach. I really want to get away from having to modify the web.xml for every single type of report that I can generate.
    Thanks!!
    -Javier Delgadillo
    Message was edited by:
    javidel

    Our web app is a web service where all requests get processed by an XFire servlet. So just adding the jsp on the disk somewhere won't do the trick. I have to register the jsp's.
    Is there a better way to do this?
    -Javier

  • How to configure ADF application to use OAM Identity Assertion ? web.xml

    We have a web application developed using ADF (application development framework) and deployed on WebCenter 11.1.1.2 (weblogic 10.3.2)
    OID Authentication and OAM identity assertion is configured in WebLogic 10.3.2 .
    How to configure security in ADF application (web.xml or weblogic.xml) so that it uses OAM identity assertion (already configured as authentication providers in weblogic server)
    Any pointers or documentation so that application (developed using ADF) check for identity tocken and verifies it with one of identity assertion providers.

    John,
    I have to concur. With OAM you don't need this. OAM intercepts the calls and inserts a cookie for WLS to get user information from.
    I strongly advise to go through the above mention OFM Security Guide. Esp. Chapter 10 tells you in every detail how to implement OAM SSO with WLS (with or without OHS as a proxy).
    Reading this chapter saves you time and turnarounds on this topic...
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Need Jsp file to parse xml dom file

    Hai SDN member,
    I am new to jsp. I am having one xml dom file with follwing content,
    My XMLDOM file
    <root>
    <dir>
    <dirname>Mydir1</dirname>
    <file>
    <filename>f1</filename>
    </file>
    <file>
    <filename>f2</filename>
    </file>
    <dir>
    <dirname>mydir2</dirname>
    <file>
    <filename>f1</filename>
    </file>
    </dir>
    </dir>
    </root>
    This is my XML dom file. I need a sample jsp file which shoule parse the above content.
    Pls help me

    JSTL has an <x:parse> element, doesn't it? At any rate "I need JSP code" sounds very much like a JSP question to me. There's a JSP forum.

Maybe you are looking for

  • Inconsistent datatypes error when inserting into a object

    I am trying to insert some test data into the table emp.I have managed to succesfully create the objects and types but when I try to insert into the emp table I get a inconsistent datatypes error however I have checked the datatypes and they all seem

  • ORA- 600 internal error code : [17070],[],[],[],[]

    Hi All, We have observed this error in a production database. ORA-00600: internal error code, arguments: [17070],[],[],[],[],[],[],[] Can any of you kindly through some light on this issue. When does this error with this argument arise? What is the r

  • Can't tell what it is? Ad Malware? Not a pop-up

    New Mac Pro Lion Updated Firefox Left Firefox running like I always do. This AM I had two large ads on my desktop.(Netflix and I think Mac Machine) I was so upset I closed them fast. I don't think they had a menu bar. What I remember is an ad with no

  • How to reconcile customer balances with control accounts

    Hi! Sanjay Here, 1. how to reconcile the customer balances  pl. explain in details. 2. how to reconcile the customer balance with control accounts 3. how to do the automatic clearing through T code f.13. pl. give us the screen shots if available. 4.

  • Best way to transfer file between two web apps

    I'm looking for some architectural suggestions. Seems like a simple problem, but I'm really struggling. -- Problem: We have two web servers, both running apps in JBoss. I need to pass a file of roughly 20MB from one server to the other, and get the o