Servlets within web.xml

          I am using WLS 5.1.0 with SP6.
          Previously I was controlling servlet access via an ACL in the weblogic.properties file.
          I have now moved the servlet into the web.xml file and specified
          some security constraints on this servlet. I can access the servlet. However regardless of what type of security I specify I cannot control access of the server by anything other than the guest user. Here is the web.xml file I have been using.
          <servlet>
          <servlet-name>AuthServlet</servlet-name>
          <servlet-class>com.myapp.web.servlet.AuthServlet</servlet-class>
          </servlet>
          <servlet-mapping>
          <servlet-name>AuthServlet</servlet-name>
          <url-pattern>auth</url-pattern>
          </servlet-mapping>
          <security-constraint>
               <web-resource-collection>
                    <web-resource-name>Test Deployment Descriptor</web-resource-name>
                    <description>Test Deployment Descriptor for test Authentication Servlet.</description>
                    <url-pattern>/cam/auth</url-pattern>
                    <http-method>GET</http-method>          
                    <http-method>POST</http-method>
               </web-resource-collection>
               <auth-constraint>
                    <role-name>MarkEngstrom</role-name>
               </auth-constraint>
               <user-data-constraint>
                    <transport-guarantee>NONE</transport-guarantee>
               </user-data-constraint>
          </security-constraint>
          <login-config>
               <auth-method>FORM</auth-method>
               <realm-name>default</realm-name>
          <form-login-config>
                    <form-login-page>/form.jsp</form-login-page>
                    <form-error-page>/error.jsp</form-error-page>
               </form-login-config>
          </login-config>
          Note : the <role-name> is a user I have specified in my weblogic.properties file. I am using the default security realm.
          I don't get any exceptions reported in the log files and I think it must be some configuration I have missed because the security constraints appear to be totally ignored.
          Does anyone have any suggestions ?.
          Thanks,
          Mark Engstrom
          

          hi, I pump to the same problem before.
          I think you url mapping when you define web resource should starts with /, or
          you say url pattern to be *
          Good luck
          "MarkE" <[email protected]> wrote:
          >
          >
          >I am using WLS 5.1.0 with SP6.
          >Previously I was controlling servlet access via an ACL in the weblogic.properties
          >file.
          >
          >I have now moved the servlet into the web.xml file and specified
          >some security constraints on this servlet. I can access the servlet.
          >However regardless of what type of security I specify I cannot control
          >access of the server by anything other than the guest user. Here is
          >the web.xml file I have been using.
          >
          > <servlet>
          > <servlet-name>AuthServlet</servlet-name>
          > <servlet-class>com.myapp.web.servlet.AuthServlet</servlet-class>
          > </servlet>
          >
          > <servlet-mapping>
          > <servlet-name>AuthServlet</servlet-name>
          > <url-pattern>auth</url-pattern>
          > </servlet-mapping>
          >
          > <security-constraint>
          >      <web-resource-collection>
          >          <web-resource-name>Test Deployment Descriptor</web-resource-name>
          >          <description>Test Deployment Descriptor for test Authentication Servlet.</description>
          >          <url-pattern>/cam/auth</url-pattern>
          >          <http-method>GET</http-method>          
          >          <http-method>POST</http-method>
          >     </web-resource-collection>
          >     <auth-constraint>
          >          <role-name>MarkEngstrom</role-name>
          >     </auth-constraint>
          >     <user-data-constraint>
          >          <transport-guarantee>NONE</transport-guarantee>
          >     </user-data-constraint>
          > </security-constraint>
          >
          > <login-config>
          >      <auth-method>FORM</auth-method>
          >     <realm-name>default</realm-name>
          > <form-login-config>
          >           <form-login-page>/form.jsp</form-login-page>
          >           <form-error-page>/error.jsp</form-error-page>
          >      </form-login-config>
          > </login-config>
          >
          >Note : the <role-name> is a user I have specified in my weblogic.properties
          >file. I am using the default security realm.
          >
          >I don't get any exceptions reported in the log files and I think it must
          >be some configuration I have missed because the security constraints
          >appear to be totally ignored.
          >
          >Does anyone have any suggestions ?.
          >
          >Thanks,
          >
          >Mark Engstrom
          >
          

Similar Messages

  • How to set two different welcome-file to different servlets in web.xml

    Hi friends,
    Can some one help with web.xml file
    I have to different servlets in applications.
    I want to set two different welcome files for my two different
    servlets in web.xml
    Please, can some one give me sample code to achieve this.
    Here web.xml code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>     
         <servlet>
              <servlet-name>reports</servlet-name>
              <servlet-class>com.caremark.ivr.servlet.IvrReportsServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>reports</servlet-name>
              <url-pattern>/reports</url-pattern>
         </servlet-mapping>
         <session-config>
              <session-timeout>30</session-timeout>
         </session-config>
         <welcome-file-list>
              <welcome-file>reportsindex.jsp</welcome-file>
         </welcome-file-list>
         <servlet>
              <servlet-name>calldetails</servlet-name>
              <servlet-class>com.caremark.ivr.servlet.IvrCallDetailsServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>calldetails</servlet-name>
              <url-pattern>/calldetails</url-pattern>
         </servlet-mapping>
    <welcome-file-list>
              <welcome-file>calldetailsindex.jsp</welcome-file>
         </welcome-file-list>
    </web-app>
    I need this fix immediately. Your help will be really appreciated. Thanks in advance.

    First of all, my understanding is that you need to have a Servlet 2.4 complaint server to do this...Given that, you're supposed to be able to simply specify the Name of the servlet as the welcome-file to get it to work. For example:
    Your servlet section:
    <servlet>
      <servlet-name>Controller</servlet-name>
      <servlet-class>com.company.ControllerServlet</servlet-class>
    </servlet>Now you would add the following to your welcome file list:
    <welcome-file-list>
      <welcome-file>Controller</welcome-file>
    </welcome-file-list>Note that you use the servlet-name value from the servlet definition, NOT the url-mapping from the servlet-mapping section.
    Please note that I cannot verify this as I am running a 2.3 server at home. When I get to work Friday I can test on a 2.4 machine. However this shouldn't take you more than a minute to test.
    Note that I did try this on the 2.3 compliant server and it did NOT work (as I expected)...
    HTH.

  • MUST I include every servlet in web.xml??

    I am learning servlet and trying to write some codes by myself.
    When I want to invoke servlet by form, tomcat always shows that the requested resource is not available.
    I've tried some different paths for the value of ACTION, but none of them work.
    Hence, I'm wondering whether I can invoke a servlet in form without explicitly write it in web.xml??
    Could anyone generously give me an answer?

    It may be possible to configure your web server so it executes servlets with URLs like http://the.ser.ver/servlet/com.yourcompany.yourpackage.TheServlet. URLs like that are ugly and can lead to security problems so I definitely recommend against them.
    You could write a front controller servlet. Then you'll need to configure the servlets in YourFrontControllerServletConfig.xml instead of web.xml so I'm not sure if that buys you much.
    I'd just configure servlets in web.xml. That's what it is there for.
    When you write a servlet you gather requirement specs for your servlet, do architecture and technical design, graphic layout design, servlet programming, back end code programming, unit testing, jar deployment, system (& performance, security, usability, etc) testing. After all that, the task of copy&pasting ten lines in web.xml shouldn't be a terribly large task. Unless you have lost nine of your fingers in a horrible chain saw accident or something.
    (Apologies to anyone out there who has lost nine of his fingers in a terrible chain saw accident.)

  • Help needed in Mapping servlet in web.xml file

    Hi Can anyone please tell me what am doing wrong here. I can't see this servlet in my url. Please help.
    <servlet>
    <servlet-name>HelloWorld</servlet-name>
         <servlet-class>HelloWorld</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>/com/jci/fi/application/eems/HelloWorld/*</url-pattern>
    </servlet-mapping>
    package com.jci.fi.application.eems;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorld extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<body>");
    out.println("<head>");
    out.println("<title>Naveen Wants to goto TollyWood......!</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Hello World!</h1>");
    out.println("</body>");
    out.println("</html>");

    your web.xml shoould be something like this...
    <servlet>
    <servlet-name>HelloWorld</servlet-name>
    <servlet-class>com.jci.fi.application.eems.HelloWorld</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>HelloWorld</url-pattern>
    </servlet-mapping>
    Hope this helps..
    CK

  • Registered servlets in web.xml do not work....WHY????

    Hi i am executing a web application on tomcat 4.1.29 and have the following structure...the jsp pages are executed but when sendinga request to a servlet the servlets are not executed...Can somebody guide me out of this....
    webapps
    {MyApp}->[web-inf][jsp]
    {web-inf}->[classes][lib]
    {classes}->[com][src]
    {src}->[source files]
    when the source files are compiled package structure is followed and the class files are grneated in
    com.MyApp.servlets
    ...etc
    the servlets are registered in the web.xml file as shown below.....few lines of my web.xml file
    <servlet>
    <servlet-name>userServlet</servlet-name>
    <servlet-class>com.MyApp.servlets.UserServlet</servlet-class>
    </servlet>
    even then when accessing a servlet it says the resource not found
    The requested resource (/MyApp/servlet/UserServlet) is not available.
    am i missing something some where...why are the servlets not executed????

        <servlet>
            <servlet-name>UserServlet</servlet-name>
            <servlet-class>com.MyApp.servlets.UserServlet</servlet-class>
            <load-on-startup>2</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>UserServlet</servlet-name>
            <url-pattern>/User</url-pattern>
        </servlet-mapping>I'd invoke it with this URL:
    http://localhost:8080/MyApp/UserServlet
    hmm something seems to be wrong here ;-)
    URL should be
    http://localhost:8080/MyApp/User (see <url-pattern>)

  • 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

  • Eclipse, WTP, Servlets and Web.xml

    I wonder if you could help me.
    I am using Eclipse and Web Tools Platform.
    In eclipse, when I create a Servlet, I believe the servlet details (such as name, class, url-pattern) should be included into web.xml file automatically. However, this is not happening.
    Would you know how I can configure Eclipse and WTP to automatically write Servlets details into web.xml files.
    Thanls

    Thanks for the reply
    I have Eclipse 3.2 and WTP 1.5
    Yes, I am creating my Servlet in a project under the Dynamic Web Projects.
    I deploy my WAR file using the 'Export' menu.
    Now, I have manually added the servlet details into the web.xml file:
    <servlet>
    <servlet-name>HelloWorld</servlet-name>
    <servlet-class>com.mycom.HelloWorld</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>/HelloWorld</url-pattern>
    </servlet-mapping>
    I am accessing the servlet as:
    http://localhost:9090/MyFirstServlet/HelloWorld
    But I still get HTTP 404 error when accessign HelloWorld servlet. I am not sure what I am missing.
    Thanks

  • Can two urls map to same servlet in web.xml

    Hello All,
    I need to map the two urls in my web application with the same servlet.
    I tried as follows:
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee">
    <description>Empty web.xml file for Web Application</description>
    <servlet>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>fileredirectsolution.TestServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/testservlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/filerepository/*</url-pattern>
    </servlet-mapping>
    </web-app>
    However, I am getting an error while accessing the TestServlet.
    When I remove the second servlet-mapping tag..it is working fine.
    How can I map the two urls with the same servlet.
    Thanks
    Saikrishna

    it is not ur requirement. but
    i think it will help 2 u.
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4"; xmlns="http://java.sun.com/xml/ns/j2ee">
    <description>Empty web.xml file for Web Application</description>
    <servlet>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>fileredirectsolution.TestServlet<;/servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>*.xxx</url-pattern>
    </servlet-mapping>
    </web-app>
    if ur configure web.xml like above.
    any request that ends with .xxx call the TestServlet.
    ex:
    1)http://ip:port/contextpath/abc.xxx
    2) http://ip:port/contextpath/xyz.xxx
    here both urls calls the same servlet.
    -lakshman.
    save a life by sending information.
    www.help2patients.wordpress.com.

  • Configuring the web.xml to run Servlets

    Hi,
    Can i get some help to configure my web.xml file... ?
    I am trying to run servlets. Do i need to map each servlet i use or can i just create a folder and map the folder. Which web.xml file do i need to change... ? And under which directory shall i place the servlet folder.
    Thanks

    Hi,
    which server ur using ? if its tomcat then this can help u out..
    u have to change the web.xml file in ur own directory.
    for example u have ur directory in tomcat/webapps/<ur directory>
    then in ur directory u have to create 1 WEB-INF directory and copy the web.xml file in that. another thing u have to make 2 direcotries in WEB-INF.
    one is classes - u can keep ur servlets class files + ResourceProperty file
    second is lib - u can keep the library files here
    and u have to register ur each and every servlet in web.xml file
    take care
    enjoy the coading
    kedar

  • Web.xml question

    Hi Guys!
    I ran into a small problem.
    Im using the struts tiles framework to redesign a shopping cart .
    In the new framework,there are multiple websites(user interface tiles) that use the same servlets at the back end to process the requests. The control is passed back to the website that called the commonly shared servlets once the computations are done.The servlets, the various websites that use the servlets all reside on the same server and are a part of the same project.
    The whole project shares a common web.xml file.
    I was just wondering if each of the tiles can have thier own web.xml so that the servlet context can be loaded from them.
    The directory structure is like this
    Tiles Framework
    -Servlet Source
    -web.xml
    -tiles (folder)
    ---tile1(folder...contains the 1st website)
    ---tile2
    ---tile 3
    The reason being that in the older version of the shopping cart, the web.xml was used to load specfic contexts in the servlets.
    Is it possible that wach of the tiles has its own web.xml ?
    if so, does it require any configuration in the overall project.
    Thanks.

    If I understand the web.xml file correctly, there should only be one per project. But if it's just a matter of loading props for each of the tiles, can't you just have a different properties file for each tile?
    I can't imagine a situation where you'd be required to have multiple web.xml files within the same project. Can you explain why you can't just have several regular property files & read from them instead?

  • How can JSP access web.xml

    I have a JSP application that requires properties that are kept in a text file, which I am currently reading from. I would like to move these properties in the web.xml file and read them from there.
    I know how to read properties for a servlet from web.xml, however I do not know how to do this for a JSP. Can someone advise me?
    Thanks
    Matthew

    I'm not exactly sure what you are looking for, but if it's something you can do from a servlet, then you can do it from a JSP the same way. Remember, JSPs are compiled into servlets anyway. Just use the implicit objects (HttpServletRequest request, ServletContext application, etc)

  • Servlet configuration in Weblogic 5.1.. web.xml vs weblogic.properties..

    Can someone please tell me how the <servlet> entry differs from
              weblogic.httpd.register.snoop=examples.servlets.SnoopServlet
              in weblogic properties?
              Do these perform identical functions?
              

    Yes this is the source of my confusiong. It seems to be that WL can be told
              about servlets
              two ways. Firstly through the web.xml file and also via weblogic.properties.
              I don't understand
              why the second one exists.
              "Cameron Purdy" <[email protected]> wrote in message
              news:[email protected]...
              > I only work with WAR files, so I cannot speak to non-WARd servlets with
              any
              > confidence. I know that WL could use web.xml for non-WARd servlets in
              order
              > to obtain the other information associated with the servlet:
              >
              > <!ELEMENT servlet (icon?, servlet-name, display-name?, description?,
              > (servlet-class|jsp-file), init-param*, load-on-startup?,
              > security-role-ref*)>
              >
              > --
              >
              > Cameron Purdy
              > http://www.tangosol.com
              >
              >
              > "Robert Nicholson" <[email protected]> wrote in message
              > news:[email protected]...
              > > If what you say is true then why is there the need to also tell WL about
              > the
              > > servlets themselves?
              > >
              > > Presumably this is for when the servlets exist outside of a WAR then?
              > >
              > > "Cameron Purdy" <[email protected]> wrote in message
              > > news:[email protected]...
              > > > The weblogic.properties tells WL to load a WAR or specific servlet.
              The
              > > > <servlet> entry (I assume you refer to
              > > > http://java.sun.com/j2ee/dtds/web-app_2_2.dtd) defines the presence of
              a
              > > > servlet within a WAR (a deployment unit):
              > > >
              > > > >
              > > > The servlet element contains the declarative data of a
              > > > servlet. If a jsp-file is specified and the load-on-startup element is
              > > > present, then the JSP should be precompiled and loaded.
              > > > [end-quote]
              > > >
              > > > In the case of a WAR deployment, you have to tell WL that the WAR
              > exists,
              > > > then it will look in the WAR and figure out what servlets are there
              from
              > > the
              > > > <servlet> tags in your web.xml. You set up a WAR in the
              > > weblogic.properties
              > > > as such:
              > > >
              > > > weblogic.httpd.webApp.<http-path>=<os-path>
              > > >
              > > > For example:
              > > > weblogic.httpd.webApp.website=c:/weblogic/website.war
              > > >
              > > > --
              > > >
              > > > Cameron Purdy
              > > > http://www.tangosol.com
              > > >
              > > >
              > > > "Robert Nicholson" <[email protected]> wrote in message
              > > > news:[email protected]...
              > > > > Can someone please tell me how the <servlet> entry differs from
              > > > >
              > > > > weblogic.httpd.register.snoop=examples.servlets.SnoopServlet
              > > > >
              > > > > in weblogic properties?
              > > > >
              > > > > Do these perform identical functions?
              > > > >
              > > > >
              > > >
              > > >
              > >
              > >
              >
              >
              

  • Using Servlet Parameters defined in web.xml

    Hi all,
    would like to use some of the properties of the UIX-Servlet within my UIX application (they may be configured in web.xml).
    But how to get to the Servlet? Typically, one just gets a BajaContext which does not provide access to the servlet itself....
    any ideas?
    Thanx, Ernst.

    Try these:
      Servlet      servlet = bajaContext.getService(Servlet.class, null);
      ServletConfig config = bajaContext.getService(ServletConfig.class, null);

  • Web service and servlets in the same project...web.xml?

    Hello, I have a problem with my web service.
    I have a server, which displays a web service. I programmed this service with JAXRPC.
    I have a client, in another directory. I succeded in compiling, deploying and running the web service.
    The problem is that after I tried to integrate this service in an existing project. This project contains servlets. In these servlets, I'm using sessions.
    These servlets are on the same side as the server of the web service. Because of the implementation of my code, I'd like to use in the class that represents the server of the service, the same session as the one I'm using in the servlets.
    But of course, it's not working by itself. I know there's something to do with the web.xml files.
    The thing is that I created a web.xml file for the service, and another for the servlets.
    I was thinking of joining both of them in one xml file, but everything crashes then...
    Could someone tell me how to create a project with a web service and servlets, and mostly how to configure the xml file??
    Thanks for any help
    Philippe

    Hello, I have a problem with my web service.
    I have a server, which displays a web service. I programmed this service with JAXRPC.
    I have a client, in another directory. I succeded in compiling, deploying and running the web service.
    The problem is that after I tried to integrate this service in an existing project. This project contains servlets. In these servlets, I'm using sessions.
    These servlets are on the same side as the server of the web service. Because of the implementation of my code, I'd like to use in the class that represents the server of the service, the same session as the one I'm using in the servlets.
    But of course, it's not working by itself. I know there's something to do with the web.xml files.
    The thing is that I created a web.xml file for the service, and another for the servlets.
    I was thinking of joining both of them in one xml file, but everything crashes then...
    Could someone tell me how to create a project with a web service and servlets, and mostly how to configure the xml file??
    Thanks for any help
    Philippe

  • 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

Maybe you are looking for

  • How many bays are available for ram

    I heard that the imac G5 has 512 built in and only one RAM slot. can someone confirm this. this is for the 2.1 20" imac G5 thanks

  • Difference between Drill down Report and Interactive Report

    What is the difference between Drill down Report and Interactive Report?

  • CS2, win, loading fonts

    I'm working primarily in Illustrator, but this question may pertain to all the CS2 programs. When I first open Illustrator in the morning, I find myself waiting for what seems like 5 minutes for all my fonts to load. Is there a way to open the progra

  • Render Video - Quicktime Disabled

    I'm in the render video dialog and quicktime option is disabled. It wasn't a little while ago when I was playing. I can not find in the help topics why. Might somebody be able to help me un-disable it? Thanks Mathias

  • MTP quest

    I am a little puzzled here. I decided to load the v2 firmware onto my Micro, mainly out of curiosity (I don't use any "to go" services). I had thought that MTP firmware would allow me to use Windows Explorer directly to transfer music, without any ex