Mapping an url-pattern to a servlet in a hosted environment

This may not be exactly the right place for this, but I thought someone may have had similar experiences and be able to suggest something...
My JSP/Servlet application runs fine in a Tomcat -standalone environment, however there are certain mappings (hrefs and what-not) that do not function when I upload it to the hosted environment I am using. For example, the index page contains a link to something like /xyz. /xyz is an url-pattern specified in my web.xml that is then mapped to a servlet. The hosted application gets an Apache 404 when following such a link, because (the hosting help desk tell me) by default the only requests that Apache forwards to Tomcat are /*.jsp, /*.xml and /servlet/*, as defined in their httpd.conf.
Are any of the following possible?
1. They introduce somes line into the Tomcat section of their httpd.conf forwarding requests like myHostedSite/xyz to my instance of Tomcat (and so not forwarding theirOtherHostedSites/xyz).
2. (My preferred shot-in-the-dark) They introduce a line into their httpd.conf that, for my site, then references another configuration file (on my part of the system), in which I could maintain a list of mappings that Apache should forward to Tomcat.
Otherwise, I guess, I am left to change all refences in my code and pages from /xyz to /servlet/xyz which is ugly and feels like a kludge.
Any hints, tips, help or advice (or even directions to a better place to post this) gratefully received.

For Point 2, surely they are using a Virtual Host for your app on tomcat? this means they should be able to configure ALL requests to Tomcat based on your Virtual Host. Unless of course your using thier host name and utilising only the context path???
The httpd.conf should have something like:<VirtualHost your.domainName.com:80>
    ServerAdmin [email protected]
    DocumentRoot /path/to/your/app
    ServerName your.domainName.org
    ErrorLog /path/to/error/log
    CustomLog /path/to/custom/log
    JkMount /*.jsp worker1 //your worker.properties file
    JkMount /*.html worker1 //your worker.properties file
</VirtualHost>With the DocumentRoot set it should default all your gifs, jpegs etc but route htmls, jsps and servlets through to your tomcat instance as configured with your worker.properties file.
I have to admit, Apache to Tomcat integration can be a nightmare and the Apache httpd.conf file is a monster but the above code should work provided you have yout own domain name.
Regards,
Anthony

Similar Messages

  • Different url-patterns for same servlet running in 2 different environments

    Hi All,
    I have a question about url mappings in my web.xml file and I hope somebody can help. The situation is that I�m putting together a web app using a combination of JSPs and servlets. I can�t develop on the machine that it will be hosted on, so I�m working and testing on my own machine and will transfer to the host machine when finished. However, the host machine is set up to map serlvets to http://�/servlet/MyServlet but the copy of tomcat I have installed locally maps to http://�/MySerlvet. My question is, when I get ready to transfer my application do I have to go through all my code and find serlvet references and insert the �servlet/� path info required by the hosting service, or can I just change the url patterns for the servlet mappings of the web.xml file on the host machine ? In other words:
    Local install of Tomcat where servlets are accessed at http://�/MyServlet
    <servlet-mapping>
    <servlet-name> MyServlet </servlet-name>
    <url-pattern>/MyServlet </url-pattern>
    </servlet-mapping>
    Host machine install of Tomcat where servlets are accessed at http://�/servlet/MyServlet
    <servlet-mapping>
    <servlet-name> MyServlet </servlet-name>
    <url-pattern>/servlet/MyServlet </url-pattern>
    </servlet-mapping>
    I guess my thinking is that it would be better/easier to have a remote and local version of the web.xml file that reflects the environment each one resides in and have only one codebase rather than 2 codebases and 1 web.xml file. Am I thinking about this in the right way, or have I misunderstood something?
    Thanks,
    Peter

    What you�re suggesting is logical, but won�t that
    effect all the other stuff I�ve got running on my
    local Tomcat install that expects servlets to be
    accessed at http://.../ServletName ?
    in web.xml, you decide of your mapping, so you could use the /servlet/ServletName pattern for your application that needs to be remote, and /ServletName for the rest of your stuff. You can even define more than one mapping for a servlet...
    In fact, you should probably put your whole application that is going to be on a remote server in it's own context, and to be ahead of dufymo :-) , learn to put it a war file for deployment.

  • Mapping webapp URLs to a single servlet which forwards to JSP

    I am using JSP for page presentation, but I want to have all requests
              intercepted by a servlet, which will perform various functions before
              forwarding to the requested JSP page. In general, I want the URL to
              reflect the target JSP page, to facilitate bookmarking. I'm using a
              web application to deploy the servlet+JSPs.
              Ideally, I wanted to have all request URLs look like a request for the
              JSP page without the .jsp extension (so
              http://hostname/webapp/here/there maps to /here/there.jsp within
              webapp). However, I can find no provision in web.xml for mapping all
              URLs without extensions to a specific servlet. I can use '/' to map
              all requests to the servlet, but then even image or HTML requests
              get intercepted (and trashed).
              On the other hand, if I map '*.jsp' to the servlet, then when I try to
              forward to the actual JSP page, the servlet gets invoked again
              recursively.
              I could create an arbitrary extension and map it to the servlet, and
              then have the servlet replace my custom extension with '.jsp' before
              forwarding, but this seems a bit funky.
              Has anyone come up with a better solution to this, within the context
              of a webapp? Seems like it should be a not-uncommon scenario.
              Thanks,
                                  -- Peter
              

    Yes, you can! It depends on how you access the servlet. If you access it via GET method you must add a request parameter to the url to distinguish from which jsp the request comes. If you use POST method (with form submission) put a hidden field in the form and with that field you can recognize from which jsp the request comes.
    Message was edited by:
    amittev

  • Url-pattern

    Hi,
    below is the code for filter url mapping.
    "<url-pattern>/gbsUploadSummary.jsp</url-pattern>" .I have a problem with this line...its nt executing....can i know the mistake...
    <filter>
    <filter-name>DumpFilter</filter-name> <filter-class>com.pwc.webectm.util.DumpFilter</filter-class>
    <init-param>
    <param-name>dumpRequest</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>dumpResponse</param-name>
    <param-value>true</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>DumpFilter</filter-name>
    <url-pattern>/gbsUploadSummary.jsp</url-pattern>
    </filter-mapping>

    What exact URL do you supply? (You can omit the host for privacy if you like, but you have likely already supplied it in your original post). I am confused about what you are asking. Are you saying that you can see the output of your JSP but not any code in your filter? My guess is the dump filter is relatively trivial (e.g., outputing the request and response received). Can you post the code? Is there a possibility you are not reading your init params correctly?
    It is one of the following:
    1. The filter mapping in web.xml does not match that which you are sending in your request in the browser address bar (most likely, but hard to tell)
    2. You are not reading your init params correctly so that 'true' is not being evaluated and you are in essense skipping over your own code blocks (hard to tell without the filter code itself, but you could easily verify by putting a logging statement in the first line of doFilter()).
    3. You have an error in your code that is causing the filter not to initialize (there should be an exception in the logs in this case)
    4. Related to #2, there is a simple coding error in the filter itself preventing you from seeing output
    - Saish

  • How to specify  a servlet mapping as the url pattern with in the security constraints

    Hi ,
    Weblogic 6.0 documentation says the following:-
    Define which resources in the Web Application the security constraint applies to using the <url-pattern> element that is nested inside the <web-resource-collection> element. The <url-pattern> can refer to either a directory, filename or a <servlet-mapping>.
    To apply the security constraint to the entire Web Application, use the following <url-pattern>:
    <url-pattern>/*</url-pattern>
    Could any one let me know how to specify servlet mapping as the url pattern.
    I tried various combination and it doesn't seem to work and any help in this regard will be greatly appreciated.
    Thanks
    kannan

    The answer is posted here:
    Unapproved User Flag in UME

  • url-pattern for extension mapping in security-constraint not working

    I'm trying to use extension mapping in a <security-constraint> configuration,
    According to:
    http://download.oracle.com/otn-pub/jcp/servlet-3_1-fr-eval-spec/servlet-3_1-final.pdf?AuthParam=1429824454_de04222eab1b8…
    Section 12.2:
    A string beginning with a ‘*.’ prefix is used as an extension mapping.
    But WebLogic does not take in consideration my configuration. If I use path mapping exact mapping it work.
    My configuration is:
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Unsecured</web-resource-name>
            <url-pattern>*.wsdl</url-pattern>
            <url-pattern>*.xsd</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>HttpAuth</web-resource-name>
            <url-pattern>/ws/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>ws-user</role-name>
        </auth-constraint>
        <user-data-constraint>
            <transport-guarantee>INTEGRAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>Test1</realm-name>
    </login-config>
    <security-role>
        <role-name>ws-user</role-name>
    </security-role>
    WebLogic Server 12c (12.1.3)
    Has anybody used extension mapping with security-constraint? Is that a WebLogic issue?

    Hi nikita,
    I have delt with the same problem before. As you say, most JSF actions all get posted back to the original page, and the faces servlet internally redirects according to the navigation rules and actions. This can mean the URL seen by the browser does not always correspond to the actual JSP (wrapped by JSF) that produced the content.
    Generally adding the "<redirect/>" tag to all your navigation rules (in faces-config.xml) remedies this, so the actions are still posted back to the original page, but then the JSF servlet sends an http-redirect to the browser before invoking the new page. This way, the URL is always in sync, and the security constraints defined in your web descriptor always get invoked properly.
    regards,
    tony

  • PLEASE HELP Can't run my servlet url-pattern with Tomcat

    Hi I'm trying to run servlet with Tomcat.
    I have don the servlet with tomcat ide abd its runnig ok with Forte with the internal Tomcat
    When I'm runing it with external Tomacat its not running at the url that I have given in the web.xml
    web.xml file:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    <servlet-name>ClaimsServlet</servlet-name>
    <servlet-class>ild.claims.ClaimsServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>ild.claims.LoginServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ClaimsServlet</servlet-name>
    <url-pattern>/ild/claims/claims</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/ild/claims/LoginServlet</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    90
    </session-timeout>
    </session-config>
    <welcome-file-list>
    <welcome-file>
    default.jsp
    </welcome-file>
    <welcome-file>
    index.html
    </welcome-file>
    <welcome-file>
    index.htm
    </welcome-file>
    </welcome-file-list>
    </web-app>
    if I runnig the url: /ild/servlet/ild/claims/ClaimsServlet
    its running
    but //ild/claims/claims
    I got: The requested resource (/claims/claims) is not available.
    Thanks for help
    Snir

    Do you have to use <url-pattern>/ild/claims/claims</url-pattern>
    or you can use <url-pattern>/claims</url-pattern> ?

  • Servlet Filters/url patterns with WLS 8

    Hello,
    I am trying to use filters to do some pre processing before my web service
    is invoked. It seems the doFilter() method does not seem to be getting invoked.
    The init() method is getting invoked as I see print statements in the log file.
    I am not sure if the url-pattern is correct and I am enclosing the web.xml file
    here along with relevant lines from web-services.xml and application.xml.In access.log
    I do see HTTP calls to the web service.
    Any help would be appreciated.
    <web-app>
    <filter>
    <filter-name>l10nWebServiceFilter</filter-name>
    <filter-class>com.globalsight.dotNet.L10nWebServiceFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>l10nWebServiceFilter</filter-name>
    <url-pattern>/l10nWebService/*</url-pattern>
    </filter-mapping>
    </web-app>
    From web-services.xml -
    web-service useSOAP12="false" targetNamespace="http://localhost:7001/L10nWebServiceEJB"
    name="L10nWebServiceEJB" style="rpc" uri="/L10nWebServiceEJB">
    and from application.xml -
    <application>
    <display-name></display-name>
    <module>
    <web>
    <web-uri>l10nWebService.war</web-uri>
    <context-root>l10nWebService</context-root>
    </web>
    </module>
    <module>
    <ejb>cap_ssb.jar</ejb>
    </module>
    </application>

    Hi Aswin,
    I think the problem may be in your Servlet Filter code :-)
    The last line in your doFilter() method should be:
    filterChain.doFilter(servletRequest, servletResponse);
    I have attached a small zip that uses a ServletFilter to get around situations,
    where the WLS web services stack/tools has problems dynamically generating the
    WSDL I want to present to the "outside world". It (the zip) contains a web.xml
    that illustrates how to set the <url-pattern>. This web.xml goes with the web-services.xml
    in the web services' .war, but the ServletFilter is "generic" :-)
    HTH,
    Mike Wooten
    "Aswin Dinakar" <[email protected]> wrote:
    >
    Changing the url-pattern to /* solved the problem and the doFilter()
    method is
    being called. However the webservice is not being invoked now. Is there
    any changes
    to web-services.xml that I need to make that after the doFilter() code
    is invoked
    the webservice methods would be invoked ?
    Thanks,
    Aswin.
    "Aswin Dinakar" <[email protected]> wrote:
    Hello,
    I am trying to use filters to do some pre processing beforemy
    web service
    is invoked. It seems the doFilter() method does not seem to be getting
    invoked.
    The init() method is getting invoked as I see print statements in the
    log file.
    I am not sure if the url-pattern is correct and I am enclosing the web.xml
    file
    here along with relevant lines from web-services.xml and application.xml.In
    access.log
    I do see HTTP calls to the web service.
    Any help would be appreciated.
    <web-app>
    <filter>
    <filter-name>l10nWebServiceFilter</filter-name>
    <filter-class>com.globalsight.dotNet.L10nWebServiceFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>l10nWebServiceFilter</filter-name>
    <url-pattern>/l10nWebService/*</url-pattern>
    </filter-mapping>
    </web-app>
    From web-services.xml -
    web-service useSOAP12="false" targetNamespace="http://localhost:7001/L10nWebServiceEJB"
    name="L10nWebServiceEJB" style="rpc" uri="/L10nWebServiceEJB">
    and from application.xml -
    <application>
    <display-name></display-name>
    <module>
    <web>
    <web-uri>l10nWebService.war</web-uri>
    <context-root>l10nWebService</context-root>
    </web>
    </module>
    <module>
    <ejb>cap_ssb.jar</ejb>
    </module>
    </application>
    [webservice_servlet_filter.zip]

  • Problems With url-pattern in a filter-mapping

    Hi!
    I need to make a filter when the clients call a jsf pages in /pages in my web application, but when i make the filter-mapping like this:
         <filter-mapping>
              <filter-name>sessionFilter</filter-name>
              <url-pattern>/pages/*.jsf</url-pattern>
         </filter-mapping>An exception appears:
    SEVERE: Parse error in application web.xml
    java.lang.IllegalArgumentException: Invalid <url-pattern> /pages/*.jsf in filter mapping
         at org.apache.commons.digester.Digester.createSAXException(Digester.java:2540)
         at org.apache.commons.digester.Digester.createSAXException(Digester.java:2566)
         at org.apache.commons.digester.Digester.endElement(Digester.java:1061)
         at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(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.commons.digester.Digester.parse(Digester.java:1548)
         at org.apache.catalina.startup.ContextConfig.applicationConfig(ContextConfig.java:263)
         at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:624)
         at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:216)
         at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4290)
         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
         at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
         at org.apache.catalina.core.StandardService.start(StandardService.java:480)
         at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
         at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
         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:324)
         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)the <url-pattern>/pages/*</url-pattern> not work to me because process all pages, I nedd only *.jsf
    Please Help me whit this.

    "the <url-pattern>/pages/*</url-pattern> not work to me because process all pages, I nedd only *.jsf"
    Yes but in the filter you can get the url from the request.getUrl() and then only process requests that contain .jsf. Simply just pass all other requests along.
    Some information on url pattern matching:
    http://edocs.bea.com/wls/docs61/webapp/components.html#113049

  • Help about wls8.1 servlet url-pattern

    In WLS8.1, I get 404 error when url-pattern is "/*.jsp"; it is ok when url-pattern is "*.jsp". why? Thanks a lot!

    Could it be that the leading forward slash is telling the web server that you mean the context root, and the jsp files you are trying to map to are almost certianly not at the context-root of your application.

  • Filter does not work with *.jsp URL pattern???

    Hi All,
    I am, by no means, very good at JSF or Java. I have looked at various forum posts on here for ways to implement a security filter to intercept requests to pages that first require one to be logged in, and if not, redirect them to the login page. Yes, I know a lot of you have heard this many times before, and I'm sorry to bring it up again.
    BUT, from the guidance of other posts, I have got a filter that works fine when the url pattern is set to "/faces/*" or "/<anything>/*", however it won't work for "*.jsp" or "*.<anything>"
    My filter is as follows:
    package test.security;
    import javax.faces.context.FacesContext;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.http.HttpSession;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class SecurityFilter implements Filter{
        /** Creates a new instance of SecurityFilter */
        private final static String FILTER_APPLIED = "_security_filter_applied";
        public SecurityFilter() {
        public void init(FilterConfig filterConfig) {
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws java.io.IOException, ServletException{
            HttpServletRequest req = (HttpServletRequest)request;
            HttpServletResponse res = (HttpServletResponse)response;
            HttpSession session = req.getSession();
            String requestedPage = req.getPathTranslated();
            String user=null;
            if(request.getAttribute(FILTER_APPLIED) == null) {
                //check if the page requested is the login page or register page
                if((!requestedPage.endsWith("Page1.jsp")) /* This is the login page */
                    //set the FILTER_APPLIED attribute to true
                    request.setAttribute(FILTER_APPLIED, Boolean.TRUE);
                    //Check that the session bean is not null and get the session bean property username.
                    if(((test.SessionBean1)session.getAttribute("SessionBean1"))!=null) {
                        user = ((test.SessionBean1)session.getAttribute("SessionBean1")).getUsername();
                    if((user==null)||(user.equals(""))) {
                       // try {
                     //       FacesContext.getCurrentInstance().getExternalContext().redirect("Page1.jsp");
                      //  } catch (ServletException ex) {
                      //      log("Error Description", ex);
                        res.sendRedirect("../Page1.jsp");
                        return;
            //deliver request to next filter
            chain.doFilter(request, response);
        public void destroy(){
    }My web.xml declaration for the filter is:
    <filter>
      <description>Filter to check whether user is logged in.</description>
      <filter-name>SecurityFilter</filter-name>
      <filter-class>test.security</filter-class>
    </filter>
    <filter-mapping>
      <filter-name>SecurityFilter</filter-name>
      <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    Note: I have also tried this with <url-pattern>*.jsp</url-pattern> for the filter mapping in place of the Faces Servlet
    My web.xml declaration for the url pattern is:
    <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.jsp</url-pattern>
    </servlet-mapping>Which JSC/NetbeansVWP automatically creates a "JSCreator_index.jsp" which has:
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root  version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page">
      <jsp:forward page="Page1.jsp"/>
    </jsp:root>When run, this causes an Error 500 in the browser and a NullPointerException in SecurityFilter.java on the line:
    if((!requestedPage.endsWith("Page1.jsp")) /* This is the login page */I think I'm missing something that would be obvious to anyone who knows better than me. Any ideas?

    Dear Ginger and Boris,
    thanks for the information - the problem seems to ocur in EP7 as well, Boris told me it is fixed in SP15. We are on SP14 now, so there is hope !
    actually the information in the oss note stated above is also true, as we have an Oracle DB. On a similar demo system (only difference is SQL DB) the hyphen search works !
    best regards, thank you !
    Johannes

  • How do I pass the part of the url that matched url-pattern to JSP?

    Hello,
    I have a web app called ptest.war deployed in JBoss. In my web.xml I have:
    <servlet-mapping>
    <servlet-name>GetImage</servlet-name>
    <url-pattern>/images/*</url-pattern>
    </servlet-mapping>
    and:
    <servlet>
    <servlet-name>GetImage</servlet-name>
    <jsp-file>DoImageRequest.jsp</jsp-file>
    <load-on-startup>1</load-on-startup>
    </servlet>
    In DoImageRequest.jsp, I want to know what was requested by the user (so I can set some response headers and then re-direct to the image they requested), so if I go to:
    http://localhost/ptest/images/i1.jpg
    I want to have "/images/i1.jpg" available to me in the JSP, so that I can do a jsp:forward to the requested image, but none of the getters on the request object give me that string.
    request.getServletPath() returns "/images" and request.getPathInfo() returns "/i5.jpg".
    So do I need to construct what the user asked for by concatenating these two values?
    The reason I was testing this was because I wanted to set no-cache in the response to the request for the image. Is there an easier way of doing that without having to direct the request to a jsp so that the jsp can set the response headers, which seems a little long-winded to me?
    Many Thanks,
    Paul Smith

    I want to have "/images/i1.jpg" available to me in the JSP, so that I can do a jsp:forward to the requested image, but none of the getters on the request >object give me that string.Even if you manage to construct that, such a request path would be intercepted by your jsp because it maps to /images/*.
    You would end up with infinite recursion.
    To circumvent that, you can change the folder that stores the image - call it something like img and then you just need append the request.getPathInfo().
    getServletContext.getRequestDispatcher("/img"+req.getPathInfo()).forward(req,res);
    The reason I was testing this was because I wanted to set no-cache in the response to the request for the image. Is there an easier way of doing that >without having to direct the request to a jsp so that the jsp can set the response headers, which seems a little long-winded to me?You could have a filter intercept all requests for *.img, add the response headers and pass the request along to the actual resource. That would be easier and more intuitive. If your web app has a good fronting like an apache web server, I think you can cache your images on the web server and set a property that would instruct the web server to set a no-cache header in response when it serves the image.
    ram.
    Edited by: Madathil_Prasad on Mar 26, 2010 7:20 PM

  • Using security-constraint in web.xml; not recognizing url-pattern tag

    I am creating a very simple jsp application within JDeveloper 10.1.3.1. I have 2 jsp files...a readData.jsp and a maintainData.jsp. I would like to deploy this application to Oracle Application Server 10.1.2.2. I would like to use Oracle Internet Directory with Single Sign on enabled. The deployment to OAS works fine. For the security, I would like an administrator user to get to both pages...and a user to only be able to see the readData.jsp. I used the security constraints on the properties of the web.xml file within JDeveloper. Here is my web.xml file:
    <?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>
    <description>Empty web.xml file for Web Application</description>
    <session-config>
    <session-timeout>35</session-timeout>
    </session-config>
    <mime-mapping>
    <extension>html</extension>
    <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>txt</extension>
    <mime-type>text/plain</mime-type>
    </mime-mapping>
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>adm_full_access</web-resource-name>
    <url-pattern>*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>adm_all</role-name>
    </auth-constraint>
    </security-constraint>
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>usr_access</web-resource-name>
    <url-pattern>readData.jsp</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>usr_all</role-name>
    </auth-constraint>
    </security-constraint>
    <login-config>
    <auth-method>BASIC</auth-method>
    </login-config>
    <security-role>
    <role-name>usr_all</role-name>
    </security-role>
    <security-role>
    <role-name>adm_all</role-name>
    </security-role>
    </web-app>
    When I deploy to OAS I added an OID account to the adm_all role...this works fine I can log on as that user and get to both jsps. But, when I add my user to the usr_all role within OAS I try to log on to the app...I then enter my SSO username and password and I get Access Denied errors from my browser when trying to access either page. I am confused about the <url-pattern> tag...is that relative to a directory within my deployment? Most of the examples I have seen use servlets...so I was wondering if I can even use the <url-pattern> tag to restrict/allow access to individual jsps? If someone could point me to some documentation on this set-up I would appreciate it!
    Thank you.

    I was able to get this to work. By doing the following:
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>adm_full_access</web-resource-name>
    <url-pattern>*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>adm_all</role-name>
    </auth-constraint>
    </security-constraint>
    I was restricting access to all other groups by uisng <url-pattern>*</url-pattern>. Any other security-constraints set-up after that will not work. So saying * requires usr_all will restrict ALL webpages to ONLY adm_all, regardless of what future constraints say. So, my first security-constraints lists all directories or pages that every user can access. My next security-constraint then list resources that only my admins (adm_all) can acess. Any other security constraints then are set-up for each user role that I have...if adm_all should have access to these then the <role-name>adm_all</role-name> is added to each security constraint.

  • JSF url-pattern *.jsf problem

    Hi all,
    I am working in a project to add the jsf page in the existing jsp application. It uses Apache Tomcat 6.0.18 as the server and eclipse for coding.
    I created a jsf page named index.jsp and I added the code in web.xml as follows
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    <session-config>
    <session-timeout>30</session-timeout>
    </session-config>
    </servlet-mapping>
    and when I use the url
    http:localhost:8080/myproject/index.jsf
    Page did not open in the browser and browser reports page not found.
    If I change url-pattern to
    <url-pattern>/faces/* </url-pattern>
    and
    when I use the url
    http:localhost:8080/myproject/faces/index.jsp
    It works.
    What should I want to do to make
    http:localhost:8080/myproject/index.jsf to render in the browser?
    Edited by: mvg90 on Jul 24, 2009 4:22 AM

    BalusC wrote:
    I have no idea. Reinstalling the stuff is definately cumbersome. This is likely just a matter of configuration and/or the way of usage. Hard to say based on the as far given little information (read this how to ask questions the smart way and read this how to provide good code examples representing your actual problem).
    If you want you can of course redo the setup of the environment and the code based on some reliable tutorial / book.I am sorry if my information is not sufficient. What information can I give to solve the problem?

  • Wildcards in url-pattern ?

    Hi,
    Is it possible to map servlets with wildcard url-patterns such as
    <url-pattern>/stuff/*</url-pattern>
    in the OC4J used in 10gR2?
    /stuff/123123?id=foo gives a hit on Tomcat but 404 on OC4J (and the admin console shows the mapping as /stuff).

    Hello,
    It is working for me without any issue.
    Could you please copy the web.xml content that defines the servlet and its mapping?
    Also what is the topology of your OracleAS 10gR2,, are you using OHS? or it is OC4J stand alone?
    Regards
    Tugdual Grall

Maybe you are looking for