Web.xml problem and using of FrontController Pattern

I use FrontController pattern and created servlet ControllerServlet.
I want that when users open my site (for example mysite.com) all requests goes to controller? and even when users enter diretc path to jsp or servlet all requests were sent to ControllerServlet.
in my As I read in "Java Servlet and JSP CookBook" for this I have to write in web.xml file such code:
<servlet-mapping>
  <sevlet-name>ControllerServlet</servlet-name>
  <url-pattern>/*</url-pattern>
</sevlet-mapping>so any requests will be sended to my controller servlet.
But now I have other problem. How I have to call my jsp pages? When I use RequestDispatcher and forward reques to jsp pahe login.jsp, I have error because this request again redirects to controller.
PS For calling servlet I have solve of this problem I just have to add to web.xml file security-constraint element for needed servlets.

You really shouldn't have to map all urls to your ControllerServlet. Set the welcome file in the web.xml to open index.html and in index.html use JavaScript to direct the page to the ControllerServlet. Now as long as you only do RequestDispatcher forwards (no sendRedirects), all hyper links point to the ControllerServlet and all form actions point to the ControllerServlet you are okay. The reason is that the user will nevr see anything else in the browser address other than the ControllerServlet url and should never know the url of any other JSP or Servlet to request them directly.

Similar Messages

  • I  have some more problem in the  web.xml file and url-pattern in my  syste

    HI ALL!
    How can I create and place the web.xml and URL-parrten.Because I run
    the tomcat in my computer with ME system.
    Hoc

    what is the problem? please be more specific and detailed? check a sample web.xml file and make your own one and place it in your <application-context>\WEB-INF folder..

  • Web.xml problem in Enterprise Manager 10g

    I got an error while deploying to Enterprise Manager 10g
    My platform: Windows XP
    OC4J 9.0.4
    Enterprise Manager 10g
    And I even have the web.xml in the correct directory. i.e
    cpd.ear
    ./META-INF/application.xml
    ./cpd-ejb.jar/WEB-INF/web.xml
    ./cpd-webapp.war/WEB-INF/web.xml
    ./cpd-webapp.war/WEB-INF/classes
    The error I get while deploying on a Enterprise Manager 10g is:
    Invalid J2EE application file specified - Jar file: :\WINNT\TEMP\jar47575.tmp is missing its standard xml descriptor located at WEB-INF/web.xml
    Incidently the *.ear file built by my fellow's machine is deploying perfectly. I've compared the directories n useful files of both the *.ears down to the very last bit n they are the same.
    I can imagine that guys with only high IQ can solve this mystery

    The above message is a duplicate of another message by Sim.
    web.xml problem in Enterprise Manager 10g

  • Web.xml, struts and ssl

    Hi there,
    on our projects web pages we use struts, to combine the html of our pages with the java code behind. To enable SSL I added a security constraint to the web.xml:
         <security-constraint>
              <display-name>SSL Constraint</display-name>
              <web-resource-collection>
                   <web-resource-name>secured login resource</web-resource-name>
                   <description></description>
                   <url-pattern>/index.html</url-pattern>
                   <url-pattern>*.do</url-pattern>
                   <http-method>GET</http-method>
                   <http-method>PUT</http-method>
                   <http-method>POST</http-method>
              </web-resource-collection>
              <auth-constraint>
                   <description></description>
                   <role-name>authenticatedUser</role-name>
              </auth-constraint>
              <user-data-constraint>
                   <transport-guarantee>CONFIDENTIAL</transport-guarantee>
              </user-data-constraint>
         </security-constraint> Some of our web pages need to use no SSL. So I added (for first testing) a second security constraint to the web.xml and defined which pages should be without SSL:
         <security-constraint>
              <display-name>No-SSL Constraint</display-name>
              <web-resource-collection>
                   <web-resource-name>businesstransaction resource</web-resource-name>
                   <description></description>
                   <url-pattern>*.go</url-pattern>
                   <http-method>GET</http-method>
                   <http-method>PUT</http-method>
                   <http-method>POST</http-method>
              </web-resource-collection>
              <auth-constraint>
                   <description></description>
                   <role-name>authenticatedUser</role-name>
              </auth-constraint>
              <user-data-constraint>
                   <transport-guarantee>NONE</transport-guarantee>
              </user-data-constraint>
         </security-constraint>As you can see, I exchanged *.do with *.go for testing. I simply defined all actions I want to be used without SSL with a .go instead of a .do in the struts.config.
    In principle it works, but there is a problem: The default behaviour for struts seems to be that the name of the new action is posted in the url at the end of the standard starting url.
    Our url starts with https://localhost:9443/client-web/, and whatever action I start, this url text in the browser window never changes, regardless of wether the next action would be protected or not.
    First I thought my url pattern would be wrong, or the user or whatever. But then I found out, that when changing the url in the browser window by hand to http://localhost:9080/client-web/ it works. The web page then is without SSL active. And when I manually change the url while viewing a page that is meant to be SSL protected, the browser automatically changes to the SSL adress.
    But then again, moving to a page without SSL does not enforce the browser to change its adress to the no SSL String. So again, SSL is active though a non secure access would be allowed.
    Anybody has any idea how to change this default behaviour? It would be important to not only tell the server that non secure would be ok, but to actually USE non secure connection automatically.
    The internet explorer is not able to upload files in SSL mode (though any other browser is able to), and our customer insists on using IE. And to tell the users "oh, just edit the line there in the window manually and reload the page will help ... or use Firefox" will not be a suitable solution.
    Regards, Rommie.

    There is a plugin called sslext which will do most of what you need.
    http://sslext.sourceforge.net/
    I think the last time I used it I made some changes to the plugin source so that I could force non-ssl to be the default behavour unless SSL was explictily stated in struts.config, but can't remember for sure. Bottom line is it will do most of what you need and can probably be modified to do the rest without too much trouble.

  • Tomcat web.xml "display-name" using flex.messaging.MessageBrokerServlet

           Hello,
    When my web application starts with the BlazeDS servlet flex.messaging.MessageBrokerServlet defined in the web.xml we have an error because in the display-name defined at top level in web.xml we have some text containing character ':'. The error is traced to inside the function
             flex.management.BaseControl.getObjectName()
    Which gets the object name, and this function calls
       BaseControl.getApplicationId()
    which finally calls
    ServletConfig.getServletContext().getServletContextName()
    This will return or display-name from the web.xml with all  it's text. This text contains among other characters the character ':'.  We use this tag for the display in the Tomcat Manager to see version  number and other of deployed project.
    After retrieving this name it is appended in the getObjectName() function to a buffer, this StringBuffer that already contains flex.runtime. and  now this name is appended (still with all that we are using for Tomcat  Manager with ':' character and other). After the name, other things are  appended. Our problem is that, after constructing this StringBuffer an instance of javax.management.ObjectName is created. In it's constructor it takes a String name  as input. This String is parsed in base of characters ':', '*', '?',  '\n' and so on, and since we have some of these characters in our  display-name it all goes wrong.
       My question is, if this is a bug, a limitation or if it is documented that using flex.messaging.MessageBrokerServlet we can not use certain characters in the display-name of the web.xml?
       Greetings, Tim
       We are using
    Tomcat 5.5.23
    Jdk 1.5.0_14
    blazeds-src-4.0.1.17657
    part of web.xml
         <display-name>
             Version: 1.10.0.3 (01/02/2011), Environment development, AGP:  10.220.6.8:1557/AGPSVI, AGP_STAGE: host 10.220.6.8:1557/AGPSVI
         </display-name>
         <description>IMPRESA progetto con undergroung</description>
         <listener>
             <listener-class>flex.messaging.HttpFlexSession</listener-class>
         </listener>
         <servlet>
             <servlet-name>MessageBrokerServlet</servlet-name>
             <display-name>MessageBrokerServlet</display-name>
             <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
             <init-param>
                 <param-name>services.configuration.file</param-name>
                 <param-value>/WEB-INF/flex/services-config.xml</param-value>
            </init-param>
             <load-on-startup>1</load-on-startup>
         </servlet>

    I have found that this is a bug and there is an issue open at the "Adobe Bug and Issue Management System", BLZ-617. I don't know if work is in progress, but when that issue is closed the problem will be solved.
      Greetings, Tim

  • JSP file not found. server.xml/web.xml problem?

    Hi there,
    I have a login.jsp that accepts username and password. Once login is approve, it calls main.jsp file as follows using <jsp:forwards>:
    if (login != null){
    out.println("Login Successful!");
    session.setAttribute("sessionUsername", username);
    session.setAttribute("sessionPassword", password);
    out.println("session started!");%>
    <jsp:forward page="main.jsp" />
    Problem is that the server returns "file not found", when I'm sure the main.jsp is right there! I suspect there is some configuration problem with the Tomcat, but I donno what. Do I need to edit the server.xml or web.xml, coz I didn't?

    please check that the jsp file to which you are forwarding the request exist at the same location where forwarding jsp exists.

  • Descriptor web.xml problem !!

    Hi!, I`m trying to create a .war file that contains a group of .jsp files and another group of EJB(Session Beans).
    The problem is that i dont know what things i have to put in the web.xml file. I only found examples with 1 EJB and servlets(No JSP !!), but it doesnt help me.
    Does anyone know which must be the structure of the file ?. I even dont know if all the information about the EJB's and JSP's must be in the web.xml file or in other files if i want to create a unique .war archive.
    Thanks a lot !!!
    CristiAn.

    If you want to have EJBs, servlets and jsps together in one file, then you should create an ear file. War files are used only for web applications, that contain jsps and servlets only.
    Check : http://java.sun.com/j2ee/1.4/docs/tutorial/doc/WebApp.html
    and http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Ebank.html.
    Regards,
    D.

  • Forte & web.xml problem

    Hi there,
    I hope what I have is a simple problem to fix. I'm running Forte For Java 4 and developing a web application. When I run a servlet (although it works fine) I am getting a run-time error:
    ContextConfig[] Configuration error in application web.xml
    java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name ChooseUnit
    This has something to do with the fact that I renamed one of my servlets and it didn't update web.xml (when I ran this servlet, it kept trying to use the servlet's old name in the URL). I went into web.xml and added this servlet's new name manually but it still didn't work, so I deleted the offending servlet, making sure that its servlet mappings were also gone from web.xml.
    I then made a new servlet of a different name, and every time I run it I get the above error, even though the servlet name in the error no longer exists, nor any reference to it in web.xml.
    Anyone got a suggestion as to how to fix this? It seems to be a bug particular to Forte.
    Thanks.
    Gillian Klee

    Never mind, it seems to have sorted itself out with a reboot.

  • Help! web.xml security without using WAR files

    I'm currently using the RDBMSRealm and URL ACL security for my app. I would like to use the web.xml descriptor for security so that I can specify login pages and such. We currently are not using WAR files. I've been having alot of trouble setting this up. Is there a way to use the RDBMS realm along with the web.xml security? It looks like it should work, but I can't seem to get it to function. How do I specify the regular document root as a webapp? I'm currently running WLS 5.1 with SP4. Thanks.

    The RDBMSRealm is just the authentication mechanism underneath WLS versus the
    web.xml of the WebApplication which describes all the access control for that WebApp.
    the later being scoped only to that WebApp.
    you don't need to deploy in a war file, you can expand the archive into an identical
    directory structure and then just point us towards the top level of that structure.
    see: http://www.weblogic.com/docs51/classdocs/webappguide.html
    .paul
    chris wrote:
    I'm currently using the RDBMSRealm and URL ACL security for my app. I would like to use the web.xml descriptor for security so that I can specify login pages and such. We currently are not using WAR files. I've been having alot of trouble setting this up. Is there a way to use the RDBMS realm along with the web.xml security? It looks like it should work, but I can't seem to get it to function. How do I specify the regular document root as a webapp? I'm currently running WLS 5.1 with SP4. Thanks.

  • Web.Xml Mapping For using Filters in Servlets

    Hi Team
    Can any one help me in getting the correct xml mappiing for using filters
    Currently i am getting 404 error when calling any resource
    using the below mapping
    <web-app>
    <display-name>OM</display-name>
    <welcome-file-list>
    <welcome-file>Hello.html</welcome-file>
    </welcome-file-list>
    <filter>
    <filter-name>Basic Filter</filter-name>
    <filter-class>BasicFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>Basic Filter</filter-name>
    <url-pattern>/sample1</url-pattern>
    </filter-mapping>
    <servlet>
    <servlet-name>sample2</servlet-name>
    <servlet-class>com.ustri.xml.FilteredServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>sample2</servlet-name>
    <url-pattern>/sample1</url-pattern>
    </servlet-mapping>
    </web-app>
    Thanks
    santhosh

    As the messages tries to suggest, the elements under <web-app> must appear in a specific order. In particular the <filter> elements, if any, must appear before any <session-config> elements. That isn't the case in what you posted so it fails validation by the DTD.

  • Web.xml problem in tomcat web hosting site

    Hi i need help in this... its urgent
    currently i just subscribe to a web hosting site and i need to start the private tomcat in the web server..
    The followings are the instructions and i have follow them but i do not know how to create a web.xml file to store in the folder indicated for example a HelloServlet that im testing :
    To setup servlet, you need to configure servlet into the file web.xml which needs to be placed in /var/www/html/WEB-INF directory.
    www root directory or webapps:/var/www/htm
    Classes directory located in: /var/www/html/WEB-INF/Classes/
    There you will need to upload your Java class file.
    Our default url-mapping for servlet is: /servlet/*
    To check servlet in your browser: www.mydomain.net/servlet/HelloWorld
    Jsp Files - Upload anywhere in /var/www/html
    all the above steps are follow except the web.xml file which i suppose to write and store in the folder... but i actually try to write one but i still cannot load my servlet on the webpage... test on standalone tomcat works.
    pls help its urgent!!!

    Please don't cross post
    http://forum.java.sun.com/thread.jsp?thread=500509&forum=45&message=2366915

  • JDev 10.1.3 Preview Create orion-web.xml Problem

    When I use JDev 10.1.3 to create an orion-web.xml file, it generates something like this:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <orion-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-web-10_0.xsd" schema-major-version="10" schema-minor-version="0" servlet-webdir="/servlet/"/>
    Shouldn't it create something without the closing "/>" marker on the <orion-web-app> line?
    9.0.5 did something like:
    <orion-web-app servlet-webdir="/servlet/">
    </orion-web-app>

    If the orion-web-app element does not have sub-elements
    <orion-web-app servlet-webdir="/servlet/"/>
    is equivalent to
    <orion-web-app servlet-webdir="/servlet/">
    </orion-web-app>

  • Web.xml problem in web hosting site

    Hi i need help in this... its urgent
    currently i just subscribe to a web hosting site and i need to start the private tomcat in the web server..
    The followings are the instructions and i have follow them but i do not know how to create a web.xml file to store in the folder indicated for example a HelloServlet that im testing :
    To setup servlet, you need to configure servlet into the file web.xml which needs to be placed in /var/www/html/WEB-INF directory.
    www root directory or webapps:/var/www/htm
    Classes directory located in: /var/www/html/WEB-INF/Classes/
    There you will need to upload your Java class file.
    Our default url-mapping for servlet is: /servlet/*
    To check servlet in your browser: www.mydomain.net/servlet/HelloWorld
    Jsp Files - Upload anywhere in /var/www/html
    all the above steps are follow except the web.xml file which i suppose to write and store in the folder... but i actually try to write one but i still cannot load my servlet on the webpage... test on standalone tomcat works.
    pls help its urgent!!!

    Please don't cross post
    http://forum.java.sun.com/thread.jsp?thread=500509&forum=45&message=2366915

  • Sending an XML message and using proxy at receiver end

    hi all,
    please suggest me the steps to be followed in order to send a XML message and accepting this message using proxies.
    please help me out with detailed procedure.
    thanks+regards,
    Ujwalkumar

    Hi UjwalKumar,
    Follow this link:
    /people/prateek.shah/blog/2005/06/14/file-to-r3-via-abap-proxy
    This blog gives an excellent description of 'FILE to Proxy' scenario.
    what you need is XML to proxy...i.e. your scenario is very similar to this one...only diffrence is  that  , you wont be using FCC .since your source msg is in XML format..
    Hope this helps..
    Regards ,
    Sushil

  • Web.xml problem ????

    This is my web.xml file :==>
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
    <web-app>
    <servlet>
    <servlet-name>chatAdmin</servlet-name>
    <servlet-class>ChatAdminServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>chatRoom</servlet-name>
    <servlet-class>ChatRoomServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>listRooms</servlet-name>
    <servlet-class>ListRoomsServlet</servlet-class>
    </servlet>
    <context-param>
    <param-name>ADMIN_PATH</param-name>
    <param-value>/ChatApplication/servlet/chatAdmin</param-value>
    </context-param>
    <context-param>
    <param-name>LISTROOMS_PATH</param-name>
    <param-value>/ChatApplication/servlet/listRooms</param-value>
    </context-param>
    <context-param>
    <param-name>CHATROOM_PATH</param-name>
    <param-value>/ChatApplication/servlet/chatRoom</param-value>
    </context-param>
    </web-app>
    Error after starting Tomcat in above file:-
    Starting service Tomcat-Standalone
    Apache Tomcat/4.0.1
    PARSE error at line 38 column 11
    org.xml.sax.SAXParseException: The content of element type "web-app" must match "(icon?,display-name?,description?,
    distributable?,context-param*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page
    *,taglib*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*)".
    Starting service Tomcat-Apache
    Apache Tomcat/4.0.1
    I am not getting where is error exactly please inform .

    <web-app>
    <servlet>
    <servlet-name>chatAdmin</servlet-name>
    <servlet-class>ChatAdminServlet</servlet-class>
    </servlet>[snip]
    <context-param>
    <param-name>ADMIN_PATH</param-name>
    <param-value>/ChatApplication/servlet/chatAdmin</param>
    </context-param>
    [snip]
    org.xml.sax.SAXParseException: The content of element
    type "web-app" must match
    "(icon?,display-name?,description?,
    distributable?,context-param*,servlet*,servlet-mapping*
    session-config?,mime-mapping*,welcome-file-list?,error-
    ageThe error message specifies exactly what is wrong -- namely your context-param tags need to come before your servlet tags which need to come before your servlet-mapping tags, etc...
    ncuka

Maybe you are looking for

  • Payload as a single Field

    how we can treat full file (Full payload ) as in single field. While file picking from sender end and keep the  full content as a payload in single field at source side?

  • Copy data pages from one workspace to another in JDev 10.1.2

    Hi: I have a workspace-1 that has a model and viewcontroller projects. No, I created another wrokspace-2. I created the same model. When I tried to copy the data pages from workspace-1 to workspace-2, it didn't allow me. Can't this be done? Have I to

  • Proble with control breaks

    Hi, When i use control breaks  and write a output i get astreix(*) in the output. I even tried with a local vriable but the value is not displayed in the output. i need to output the material description in the output. My code is as follows: LOOP AT

  • What should be optimizer mode

    Oracle 10g Rl- 2 (RAC) OS- HP-UX 11i Optimizer_mode parameter is all_rows in my database. It is OLTP enviornment. What should be the the optimizer in this condition?

  • OMPLUS retrieve table primary key column

    I'm trying to retrieve the primary key column associated with a table via OMBPLUS. The following command successfully returns the PK name OMB+> OMBRETRIEVE TABLE 'ODS_REGION' GET PRIMARY_KEY REGN_PKWhen I add the GET COLUMNS clause (as per API docume