JSF Request dispatching in JSF2.

Hi,
I get an unexpected error when dispatching a request.
try {
     HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
     HttpServletResponse response = (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
     ((ServletContext) FacesContext.getCurrentInstance()
               .getExternalContext().getContext()).getRequestDispatcher(
               "/xhtml/com/easypaygroup/global/view/configuration/parameter/searchparameter.xhtml").forward(request, response);
} catch (Exception e) {
     handlePropertyException(e);
}exception:
15-okt-2009 11:33:54 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
        at com.sun.faces.application.ApplicationImpl.invokeViewListenersFor(Appl
icationImpl.java:1914)
        at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImp
l.java:288)
        at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImp
l.java:243)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePha
se.java:114)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
        at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(Extensions
Filter.java:147)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
        at com.easypaygroup.framework.security.SecurityFilter.doFilter(SecurityF
ilter.java:93)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
        at com.easypaygroup.framework.entitymanager.CloseEntityManagerFilter.doF
ilter(CloseEntityManagerFilter.java:36)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:286)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.ja
va:697)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSock
et.java:889)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:690)
        at java.lang.Thread.run(Thread.java:619)Does anybody has an idea?
Thanks in advance,
Pieter

This one works
//forward JSF request
UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext, lastHistory.getUrl());
facesContext.setViewRoot(viewRoot);
facesContext.renderResponse();

Similar Messages

  • Nested request dispatches when using RequestDispatcher in a Button action

    Hi all,
    I am new to JSF so I am probably missing something very simple, please help:
    The test case is simple: I created one visual web page with one button and one normal JSP file(named test.jsp) using Netbeans 5.5 with visual web pack on Sun Application Server 9 PE. The code action for the button is as follows:
    public String button1_action() throws Exception
            ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
            HttpServletRequest request = (HttpServletRequest) context.getRequest();
            HttpServletResponse response = (HttpServletResponse) context.getResponse();
            RequestDispatcher dispatcher = request.getRequestDispatcher("test.jsp");
            dispatcher.forward(request,response);
            return null;
        }Once the JSF page is loaded and the button is clicked, this exception occurs:
    ApplicationDispatcher[WebApplication1] Servlet.service() for servlet Faces Servlet threw exception
    javax.servlet.ServletException: WEB2651: Exceeded maximum depth for nested request dispatches: 20
    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:837)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:697)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:532)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:465)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:353)
    at webapplication1.Page1.button1_action(Page1.java:242)
    Can anyone provide any advice on how to resolve this issue?

    Hi Rachel,
    As per the Servlet2.3 Javadoc:
    The pathname must begin with a "/" and is interpreted as relative to the current context root.
    If you make that change and include the complete path, then it would work fine.
    Ex:
    If your context looks like http://my.company.com/webapp1/ and if you were to have your forwardPortlet.jsp in a directory like:
    webapp1
      |
      |-> htdocs
             |
             |-> forwardPortlet.jsp
    then, your code would look like;
    RequestDiscpatcher d = request.getRequestDispatcher("/htdocs/forwardPortlet.jsp");
    HTH,
    thanks,
    harsha

  • Query Strings in Request Dispatcher Paths (PLT.16.1.1)

    I'm having trouble using query strings in a request dispatcher include to a servlet.
    I'm spitting debug out, and it looks like I'm calling:
    PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/myServlet?myparam=myparamValue");
    And myparam isn't being set for myServlet.
    The same URL ("http://myhost:myport/myPortal/myServlet?mayparam=mayparamValue)
    runs fine standalone....

    I'm not sure of the exact dates (either this month or the next). But
    JSR168 will be supported in the service pack.
    Subbu
    T-Bone said the following on 11/18/2003 09:23 AM:
    Subbu Allamaraju <[email protected]> wrote:
    There is a known bug in WLS's servlet container that results in this
    behavior. Please contact support if you need an expedited solution.Thanks, they said to wait for SP2 sometime end of November.
    Can you tell me when it will be available?
    Also, when will JSR-168 v1.0 be supported?
    Subbu
    T-Bone said the following on 10/26/2003 03:14 PM:
    I'm having trouble using query strings in a request dispatcher includeto a servlet.
    I'm spitting debug out, and it looks like I'm calling:
    PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/myServlet?myparam=myparamValue");
    And myparam isn't being set for myServlet.
    The same URL ("http://myhost:myport/myPortal/myServlet?mayparam=mayparamValue)
    runs fine standalone....

  • Problem with Non JSF Request to JSF Page

    Hi All,
    I am working on dynamic controls generation based on the request come from non jsf page
    For the first request, pageworks perfectly. but when we go for second request, it is not rendering and I am getting same old page.
    What I have identified is if I have 2 pages as JSF, application is not giving any problem.
    For this I have written small test application contains both JSF pages only.
    page1 contains 3 submit buttons.
    When submit buttons are clicked based on the request, I get, am able to see the dynamic controls.
    SO there is no problem with JSF PAGE to JSF Page Communication
    Now I have done some changes in First JSF page. Instead of submitting directly I am submitting the page through JavaScript which is nonb JSF request. There I am facing the problem and based on requested qaction I am not able to see correct rendered page based on the requested action.
    Any Idea why it is giving problem for non JSF requests??
    Thanks
    Sudhakar

    For Your Convenience in understanding the problem
    I am pasting entire test code
    Page 1 -- (here page2 is Page1 and Page1 is page2 - some naming convention errors :) )
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
        <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
        <jsp:text><![CDATA[
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    ]]></jsp:text>
        <f:view>
            <html lang="en-US" xml:lang="en-US">
                <head>
                    <meta content="no-cache" http-equiv="Cache-Control"/>
                    <meta content="no-cache" http-equiv="Pragma"/>
                    <title>Page2 Title</title>
                    <link href="resources/stylesheet.css" rel="stylesheet" type="text/css"/>
                </head>
                <body style="-rave-layout: grid">
                    <h:form binding="#{Page2.form1}" id="form1">
    <!-- Non JSF REquests -->
                        <h:commandButton action="#{Page2.button1_action}" binding="#{Page2.button1}" id="button1" style="left: 48px; top: 48px; position: absolute" value="Submit" onclick="document.forms['form1'].action='faces/Page2.jsp?id=1'; document.forms['form1'].submit(); return false;"/>
                        <h:commandButton action="#{Page2.button2_action}" binding="#{Page2.button2}" id="button2" style="left: 48px; top: 96px; position: absolute" value="Submit" onclick="document.forms['form1'].action='faces/Page2.jsp?id=2'; document.forms['form1'].submit(); return false;"/>
                        <h:commandButton action="#{Page2.button3_action}" binding="#{Page2.button3}" id="button3" style="left: 48px; top: 144px; position: absolute" value="Submit" onclick="document.forms['form1'].action='faces/Page2.jsp?id=3'; document.forms['form1'].submit(); return false;"/>
    <!-- this  is JSF request -->
                        <!--
                        <h:commandButton action="#{Page2.button1_action}" binding="#{Page2.button1}" id="button1" style="left: 48px; top: 48px; position: absolute" value="Submit" />
                        <h:commandButton action="#{Page2.button2_action}" binding="#{Page2.button2}" id="button2" style="left: 48px; top: 96px; position: absolute" value="Submit" />
                        <h:commandButton action="#{Page2.button3_action}" binding="#{Page2.button3}" id="button3" style="left: 48px; top: 144px; position: absolute" value="Submit" />-->
                    </h:form>
                </body>
            </html>
        </f:view>
    </jsp:root>Page1 Bean
    * Page2.java
    * Created on June 25, 2005, 11:08 AM
    * Copyright user
    package webapplication8;
    import javax.faces.*;
    import com.sun.jsfcl.app.*;
    import javax.faces.component.html.*;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    public class Page2 extends AbstractPageBean {
        // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Definition">
        private int __placeholder;
        private HtmlForm form1 = new HtmlForm();
        public HtmlForm getForm1() {
            return form1;
        public void setForm1(HtmlForm hf) {
            this.form1 = hf;
        private HtmlCommandButton button1 = new HtmlCommandButton();
        public HtmlCommandButton getButton1() {
            return button1;
        public void setButton1(HtmlCommandButton hcb) {
            this.button1 = hcb;
        private HtmlCommandButton button2 = new HtmlCommandButton();
        public HtmlCommandButton getButton2() {
            return button2;
        public void setButton2(HtmlCommandButton hcb) {
            this.button2 = hcb;
        private HtmlCommandButton button3 = new HtmlCommandButton();
        public HtmlCommandButton getButton3() {
            return button3;
        public void setButton3(HtmlCommandButton hcb) {
            this.button3 = hcb;
        // </editor-fold>
        public Page2() {
            // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization">
            try {
            } catch (Exception e) {
                log("Page2 Initialization Failure", e);
                throw e instanceof javax.faces.FacesException ? (FacesException) e: new FacesException(e);
            // </editor-fold>
            // Additional user provided initialization code
        protected webapplication8.ApplicationBean1 getApplicationBean1() {
            return (webapplication8.ApplicationBean1)getBean("ApplicationBean1");
        protected webapplication8.SessionBean1 getSessionBean1() {
            return (webapplication8.SessionBean1)getBean("SessionBean1");
         * Bean cleanup.
        protected void afterRenderResponse() {
        public String button1_action()  throws Exception{
            // TODO Following code was replaced by static navigation
           getSessionBean1().setId(1);       
          /* ExternalContext ctx=(ExternalContext)FacesContext.getCurrentInstance().getExternalContext();
           HttpServletRequest req=(HttpServletRequest)ctx.getRequest();
           HttpServletResponse res=(HttpServletResponse)ctx.getResponse();
           res.sendRedirect("http://localhost:18080/webapplication8/faces/Page2.jsp");
           return null;*/
            return "case1";
        public String button2_action()  throws Exception{
            // TODO Following code was replaced by static navigation
                getSessionBean1().setId(2);
          /*  ExternalContext ctx=(ExternalContext)FacesContext.getCurrentInstance().getExternalContext();
           HttpServletRequest req=(HttpServletRequest)ctx.getRequest();
           HttpServletResponse res=(HttpServletResponse)ctx.getResponse();
           res.sendRedirect("http://localhost:18080/webapplication8/faces/Page2.jsp");
           return null;*/
            return "case2";
        public String button3_action() throws Exception{
            // TODO Following code was replaced by static navigation
                getSessionBean1().setId(3);
            /*    ExternalContext ctx=(ExternalContext)FacesContext.getCurrentInstance().getExternalContext();
           HttpServletRequest req=(HttpServletRequest)ctx.getRequest();
           HttpServletResponse res=(HttpServletResponse)ctx.getResponse();
           res.sendRedirect("http://localhost:18080/webapplication8/faces/Page2.jsp");
            return null;*/
            return "case3";
    }page 2
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
        <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
        <jsp:text><![CDATA[
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    ]]></jsp:text>
        <f:view>
            <html lang="en-US" xml:lang="en-US">
                <head>
                    <meta content="no-cache" http-equiv="Cache-Control"/>
                    <meta content="no-cache" http-equiv="Pragma"/>
                    <title>Page1 Title</title>
                    <link href="resources/stylesheet.css" rel="stylesheet" type="text/css"/>
                </head>
                <body style="-rave-layout: grid">
                    <h:form binding="#{Page1.form1}" id="form1">
                        <h:panelGrid binding="#{Page1.gridPanel1}" id="gridPanel1" style="left: 96px; top: 48px; position: absolute"/>
                        <f:selectItems binding="#{Page1.radioButtonList1SelectItems1}" id="radioButtonList1SelectItems1"/>
                        <h:commandButton action="#{Page1.button1_action}" binding="#{Page1.button1}" id="button1"
                            style="left: 384px; top: 120px; position: absolute" value="Submit"/>
                        <h:commandButton action="#{Page1.button1_action}" binding="#{Page1.button1}" id="button1" style="left: 384px; top: 72px; position: absolute" value="Submit"/>
                        <h:outputLink binding="#{Page1.hyperlink1}" id="hyperlink1" style="left: 480px; top: 216px; position: absolute" value="http://www.sun.com/jscreator">
                            <h:outputText binding="#{Page1.hyperlink1Text}" id="hyperlink1Text" value="Hyperlink"/>
                        </h:outputLink>
                        <h:commandLink binding="#{Page1.linkAction1}" id="linkAction1" style="left: 456px; top: 264px; position: absolute">
                            <h:outputText binding="#{Page1.linkAction1Text}" id="linkAction1Text" value="Link Action"/>
                        </h:commandLink>
                    </h:form>
                </body>
            </html>
        </f:view>
    </jsp:root>page2 bean
    * Page1.java
    * Created on June 25, 2005, 10:52 AM
    * Copyright user
    package webapplication8;
    import javax.faces.*;
    import com.sun.jsfcl.app.*;
    import com.sun.jsfcl.data.DefaultSelectItemsArray;
    import java.util.Vector;
    import javax.faces.component.UIComponent;
    import javax.faces.component.UISelectItems;
    import javax.faces.component.html.*;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.faces.el.ValueBinding;
    import javax.faces.model.SelectItem;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class Page1 extends AbstractPageBean {
        // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Definition">
        private int __placeholder;
        private HtmlForm form1 = new HtmlForm();
        public HtmlForm getForm1() {
            return form1;
        public void setForm1(HtmlForm hf) {
            this.form1 = hf;
        private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();
        public HtmlPanelGrid getGridPanel1() {
            return gridPanel1;
        public void setGridPanel1(HtmlPanelGrid hpg) {
            this.gridPanel1 = hpg;
        private HtmlCommandButton button1 = new HtmlCommandButton();
        public HtmlCommandButton getButton1() {
            return button1;
        public void setButton1(HtmlCommandButton hcb) {
            this.button1 = hcb;
        private HtmlOutputLink hyperlink1 = new HtmlOutputLink();
        public HtmlOutputLink getHyperlink1() {
            return hyperlink1;
        public void setHyperlink1(HtmlOutputLink hol) {
            this.hyperlink1 = hol;
        private HtmlOutputText hyperlink1Text = new HtmlOutputText();
        public HtmlOutputText getHyperlink1Text() {
            return hyperlink1Text;
        public void setHyperlink1Text(HtmlOutputText hot) {
            this.hyperlink1Text = hot;
        private HtmlCommandLink linkAction1 = new HtmlCommandLink();
        public HtmlCommandLink getLinkAction1() {
            return linkAction1;
        public void setLinkAction1(HtmlCommandLink hcl) {
            this.linkAction1 = hcl;
        private HtmlOutputText linkAction1Text = new HtmlOutputText();
        public HtmlOutputText getLinkAction1Text() {
            return linkAction1Text;
        public void setLinkAction1Text(HtmlOutputText hot) {
            this.linkAction1Text = hot;
        // </editor-fold>
        public Page1() {
            // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization">
            try {
                ExternalContext ctx=(ExternalContext)FacesContext.getCurrentInstance().getExternalContext();
                HttpServletRequest req=(HttpServletRequest)ctx.getRequest();
                HttpServletResponse res=(HttpServletResponse)ctx.getResponse();
                String id=req.getParameter("id");
                if(id!=null)
                    getSessionBean1().setId(Integer.parseInt(id));
                if (getSessionBean1().getId()==1) {
                    addTextBox();
                else if (getSessionBean1().getId()==2) {
                    addCheckBox();
                    addRadio();
                else if (getSessionBean1().getId()==3) {
                    addRadio();
                   // addCheckBox();
            } catch (Exception e) {
                log("Page1 Initialization Failure", e);
                throw e instanceof javax.faces.FacesException ? (FacesException) e: new FacesException(e);
            // </editor-fold>
            // Additional user provided initialization code
        protected webapplication8.ApplicationBean1 getApplicationBean1() {
            return (webapplication8.ApplicationBean1)getBean("ApplicationBean1");
        protected webapplication8.SessionBean1 getSessionBean1() {
            return (webapplication8.SessionBean1)getBean("SessionBean1");
         * Bean cleanup.
        protected void afterRenderResponse() {
        private void addRadio() {
            HtmlPanelGrid gridPanel = new HtmlPanelGrid();
            UIComponent parent = gridPanel1;
            HtmlOutputText outputText = new HtmlOutputText();
            outputText.setValue("Some Desc");
            outputText.setId("somedesc2");
            HtmlSelectOneRadio checkBox = new HtmlSelectOneRadio();
            checkBox.setBorder(0);
            checkBox.setLayout("pageDirection");
            checkBox.setId("a3");
            UISelectItems items = new UISelectItems();
            DefaultSelectItemsArray objArray =new DefaultSelectItemsArray();
            vectDefaultSelectItemsArray.add(objArray);
            arrays=(DefaultSelectItemsArray[])vectDefaultSelectItemsArray.toArray(new DefaultSelectItemsArray[vectDefaultSelectItemsArray.size()]);
            int size =arrays.length;
            arrays[size - 1].clear();
            for (int i =0;i<10;i++) {
                arrays[size - 1].add(new SelectItem(""+i+"",""+i));
            // array.setItems(new String[] {"Yes","No" });
            items.setValueBinding("value",getValueBinding("#{Page1.arrays["+(size-1)+"]}"));
            checkBox.getChildren().add(items);
            gridPanel.getChildren().add(outputText);
            gridPanel.getChildren().add(checkBox);
            parent.getChildren().add(gridPanel);
        private void addCheckBox() {
            HtmlPanelGrid gridPanel = new HtmlPanelGrid();
            UIComponent parent = gridPanel1;
            HtmlOutputText outputText = new HtmlOutputText();
            outputText.setValue("Some Desc");
            outputText.setId("somedesc1");
            HtmlSelectManyCheckbox checkBox = new HtmlSelectManyCheckbox();
            checkBox.setBorder(0);
            checkBox.setLayout("pageDirection");
            checkBox.setId("a2");
            UISelectItems items = new UISelectItems();
            DefaultSelectItemsArray objArray =new DefaultSelectItemsArray();
            vectDefaultSelectItemsArray.add(objArray);
            arrays=(DefaultSelectItemsArray[])vectDefaultSelectItemsArray.toArray(new DefaultSelectItemsArray[vectDefaultSelectItemsArray.size()]);
            int size =arrays.length;
            arrays[size - 1].clear();
            for (int i =0;i<10;i++) {
                arrays[size - 1].add(new SelectItem(""+i+"",""+i));
            // array.setItems(new String[] {"Yes","No" });
            items.setValueBinding("value",getValueBinding("#{Page1.arrays["+(size-1)+"]}"));
            checkBox.getChildren().add(items);
            gridPanel.getChildren().add(outputText);
            gridPanel.getChildren().add(checkBox);
            parent.getChildren().add(gridPanel);
        private void addTextBox() {
            HtmlPanelGrid gridPanel = new HtmlPanelGrid();
            UIComponent parent = gridPanel1;
            HtmlOutputText outputText = new HtmlOutputText();
            outputText.setValue("Some Description for Control Text Box");
            outputText.setId("somedesc");
            HtmlInputText textField = new HtmlInputText();
            //  textField.setId("textField_"+control.getId());
            textField.setId("a1");
            HtmlOutputText outputText1 = new HtmlOutputText();
            hyperlink1Text.setValue(" ");
            hyperlink1Text.setStyleClass("bodyText");
            textField.setStyleClass("frmObjects");
            gridPanel.setColumns(3);
            gridPanel.getChildren().add(outputText);
            gridPanel.getChildren().add(hyperlink1Text);
            gridPanel.getChildren().add(textField);
            parent.getChildren().add(gridPanel);
        private DefaultSelectItemsArray array = new DefaultSelectItemsArray();
        public DefaultSelectItemsArray getArray() {
            return array;
        public void setArray(DefaultSelectItemsArray dsia) {
            this.array = dsia;
        private Vector vectDefaultSelectItemsArray = new Vector();
        private DefaultSelectItemsArray[] arrays = new DefaultSelectItemsArray[10];
        public DefaultSelectItemsArray[] getArrays() {
            return arrays;
        public void setArrays(DefaultSelectItemsArray[]dsia) {
            this.arrays = dsia;
        private UISelectItems radioButtonList1SelectItems1 = new UISelectItems();
        public UISelectItems getRadioButtonList1SelectItems1() {
            return radioButtonList1SelectItems1;
        public void setRadioButtonList1SelectItems1(UISelectItems uisi) {
            this.radioButtonList1SelectItems1 = uisi;
        private ValueBinding getValueBinding(String expression) {
            return     FacesContext.getCurrentInstance().getApplication().createValueBinding(expression);
        public String button1_action() {
            // TODO Replace with your code
            return "case1";
    }my navigation.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
                                  "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
        <navigation-rule>
            <from-view-id>/Page2.jsp</from-view-id>
            <navigation-case>
                <from-outcome>case1</from-outcome>
                <to-view-id>/Page1.jsp</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>case2</from-outcome>
                <to-view-id>/Page1.jsp</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>case3</from-outcome>
                <to-view-id>/Page1.jsp</to-view-id>
            </navigation-case>
        </navigation-rule>
        <navigation-rule>
            <from-view-id>/Page1.jsp</from-view-id>
            <navigation-case>
                <from-outcome>case1</from-outcome>
                <to-view-id>/Page2.jsp</to-view-id>
            </navigation-case>
        </navigation-rule>
    </faces-config>my managed beans xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
                                  "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
        <managed-bean>
            <managed-bean-name>Page1</managed-bean-name>
            <managed-bean-class>webapplication8.Page1</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
        <managed-bean>
            <managed-bean-name>SessionBean1</managed-bean-name>
            <managed-bean-class>webapplication8.SessionBean1</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
        <managed-bean>
            <managed-bean-name>ApplicationBean1</managed-bean-name>
            <managed-bean-class>webapplication8.ApplicationBean1</managed-bean-class>
            <managed-bean-scope>application</managed-bean-scope>
        </managed-bean>
        <managed-bean>
            <managed-bean-name>Page2</managed-bean-name>
            <managed-bean-class>webapplication8.Page2</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
        <managed-bean>
    </faces-config>

  • Urgent, creating xml files dynamically, request dispatcher problem

    hi all,
    Problem 1:
    There is a problem we are facing, while request dispatching.
    The files CBECBC.XML & CBECBC_Envelop.XML,
    both xml files. These files are created on request from the user, dynamically, and displayed on the browser,
    by including them in a jsp page.
    Here we face a problem when they are to be included into the jsp page.
    The error is the following :
    //////// Error ////////
    Could not find request dispatcher for the url CBECBC.xml
    Could not find request dispatcher for the url CBECBC_Envelop.xml
    The created files are stored in the "d:\pstudio35\desks\bank\BankWeb\".
    We are using " <jsp:include page="...."/> " (dynamic jsp include tag), to include the xml files.
    Problem 2:
    And could you just let me know how to include a xml file in a jsp file,
    so that the xml file is displayed in the exact format of xml(with the tags).
    I am using Pramati Studio 3.5
    Its urgent!!!
    Regards,
    Deepa Datar

    problem 2:
    either translate all < en > into < and > or display the XML in a textarea

  • Request dispatcher null

              The forward code we have is like
              public void forward(String url, HttpServletRequest request,
              HttpServletResponse response)
              throws ServletException, IOException
              RequestDispatcher dispatcher = getServletConfig().getServletContext().getRequestDispatcher(url);
              dispatcher.forward(request, response);
              My question is:
              As per the documents
              The pathname must begin with a "/" and is interpreted as relative to the current
              context root.
              if my URL is "http://www.abcz.com/<somepage>
              request dispatcher is null? and on one server (say A) that is a problem but other
              server(say B) when given the full URL behaves ok.
              on server A I am getting a null pointer exception , which on tracing happens to
              be the request dispatcher is null.(If http://www.abcz.com/<somepage> is URL) but
              no null pointer exception if url is "/<somepage>"
              On B its behaving fine when given the "http://www.abcz.com/<somepage> " as URL
              to the method.
              Both server A and B are running wl6. Is the difference in service pack cause of
              the problem?
              Internally does wl6 parses the URL to find a relative URL?
              Any help will be greatly appreciated.
              Thanks
              Rumpa
              

    And the reason for that is, RequestDispatcher is per application
              scope. And RequestDispatcher comes from the ServletContext which is
              the current application scope. So it has to be relative url. If you
              need to forward to an absolute url, you can use sendRedirect instead.
              Bhaskar
              "Matt Krevs" <[email protected]> wrote in message news:<[email protected]>...
              > as far as i know, you should always specify relative urls when using request
              > dispatchers
              >
              > eg
              >
              > if the entire url is
              > http://myserver/theurl
              > you would code as follows
              >
              > RequestDispatcher dispatcher =
              > getServletConfig().getServletContext().getRequestDispatcher("/theurl");
              > dispatcher.forward(request, response);
              >
              > You definitely should not use complete URLs when calling
              > getRequestDispatcher()
              >
              > what happens on the server that returns a null dispatcher if you manually
              > type the address into the browser? Does weblogic find the resource? If not
              > then you have something specified differently in your server that doesn
              > work.
              >
              >
              > "RUMPA GIRI" <[email protected]> wrote in message
              > news:[email protected]...
              > >
              > > The forward code we have is like
              > > /**********************************************/
              > >
              > > public void forward(String url, HttpServletRequest request,
              > > HttpServletResponse response)
              > > throws ServletException, IOException
              > > {
              > > RequestDispatcher dispatcher =
              > getServletConfig().getServletContext().getRequestDispatcher(url);
              > > dispatcher.forward(request, response);
              > > }
              > > /***********************************************/
              > >
              > > My question is:
              > > As per the documents
              > > The pathname must begin with a "/" and is interpreted as relative to the
              > current
              > > context root.
              > > if my URL is "http://www.abcz.com/<somepage>
              > > request dispatcher is null? and on one server (say A) that is a problem
              > but other
              > > server(say B) when given the full URL behaves ok.
              > > on server A I am getting a null pointer exception , which on tracing
              > happens to
              > > be the request dispatcher is null.(If http://www.abcz.com/<somepage> is
              > URL) but
              > > no null pointer exception if url is "/<somepage>"
              > > On B its behaving fine when given the "http://www.abcz.com/<somepage> " as
              > URL
              > > to the method.
              > > Both server A and B are running wl6. Is the difference in service pack
              > cause of
              > > the problem?
              > >
              > > Internally does wl6 parses the URL to find a relative URL?
              > >
              > > Any help will be greatly appreciated.
              > > Thanks
              > > Rumpa
              > >
              > >
              

  • Request dispatch problem

    To all
    The problem is that my request dispatching is not forwarding the request and I haven't got a clue why. I have a upload servlet which is working fine as it parses the request and the forwards you to the same jsp page or the next jsp page according to what values it extracts. However I have set up a bean to display the contentType() of each request which is sent to it from the jsp pages, however nothing is displayed when the request is forwarded from the upload servlet. this is what is happening .....
    public class upload extends HttpServlet {
    public void doPost( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException {
    HttpServletRequest request = _req;
    HttpServletResponse response = _res;
    parseMultiForm pMF = new parseMultiForm( _req );
    Hashtable values = new Hashtable();
    String param;
    while ( ( param = pMF.getNextParameter()) != null) {
    String value = pMF.getParameter();
    values.put(param, value);
    if (values.containsKey("submit")) {
    String url = (String) values.get("reload");
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/" + url);
    dispatcher.forward(request, response);
    if (values.containsKey("continue")) {
    String url = (String) values.get("next");
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/" + url);
    dispatcher.forward(request, response);
    The above servlet forwards the request to a jsp which does the following....
    <jsp:useBean id="info" scope="session" class="InfoBean" />
    <jsp:setProperty name="info" property="request" value="<%= request %>" />
    However infoBean does not receive anything when the request is forwarded from the servlet??
    Can anyone see anything obviously wrong?? is it to do with the JSP asking for the <%= request> and not receiving it because the request dispatcher has altered it in some way?
    Thanks in advance anyone
    Andy.

    I have exactly the same problem. I can�t make the servlet pass the request object to the target jsp.
    Try not changing the request nor the response. Unfortunatelly due to the kind of job i do inside my servlet there's no way i can't touch the request. So if you can make it work with mi advice please let me know.

  • Unable to use Request Dispatcher; Duke $ Post;

    I am using a Controller Servlet to transfer control to a JSP using Request Dispatcher within doPost()
    RequestDispatcher rd;
    rd=req.getRequestDispatcher(URL);
    rd.forward(req,resp);
    I am seting a request object
    req.setAttribute("XXX",obj.func());
    prior to the Redirect;
    The page gets redirected to a JSP. I am unable to access req object in there.
    if i use
    String XXX = req.getAttribute("XXX");
    i get an error in the jsp as
    "req cannot be resolved"
    Do i need to import some directives? Please Reply

    The page gets redirected to a JSP. I am unable to
    access req object in there.
    if i use
    String XXX = req.getAttribute("XXX");
    i get an error in the jsp as
    "req cannot be resolved"
    Do i need to import some directives? Please ReplyThat's simple. Your req (which is the HttpServletRequest object) in the servlet becomes request in the JSP. That's always there. The compiler would not recognize req
    Use request.getAttribute("XXX"); in JSP
    Regards
    ***Annie***

  • Request dispatcher between 2 servers

    dear sear:
    can i use request dispatcher to go from one servers to another whith the same session.
    thanks,
    hamdi.

    Nope, Request dispatcher works with in its servlet container.
    May be you can you Request.sendRedirect()..
    not sure.

  • Passing Attribute in Request Dispatcher

    Hi,
    I am using servlet#1 to pass the value of an Attribute to servlet#2
    servlet #1 code
    ServletContext sc = getServletContext();
    request.setAttribute("name",value);
    RequestDispatcher rd = sc.getRequestDispatcher(url);
    rd.forward(request, response);
    servlet #2 code
    ServletContext sc = getServletContext();
    String string = (String) sc.getAttribute("name");
    when I run servlet #1 request dispatcher forwards request and response to servlet #2 but the Attribute value is not passed along
    what am I missing ?
    thanks VERY much for your response in advance and past responses !!
    Rick

    Hi rickdd,
    In servlet #2 you should get the value from
    servlet's Request object rather than ServletContext,
    because parameter is set with Request Object not with
    ServletContext.
    So modifiy the code as given below...
         /* Parameter is passed with servlet's Request Object.
          * So Next line needs to be commented.
         //ServletContext sc = getServletContext();
         //Here get the value from servlet's Request Object
         String string = request.getAttribute("name");
       This will work.
    Regards
    Goodieguy

  • Request dispatcher method--help needs

    Hi,
    I used request dispatcher method to redirect the from one servlet to another servlet.But when i use get method it is functioning well.
    But when i use post method it is giving error...
    I need to use post method...
    How can it possible..
    Thanks,
    Babu B

    you have code for request.RequestDispatcher.forward(""); method in both doPost and
    doGet methods for the servlet. However your initial form is not set with method
    to POST.
    By default the method is GET and it will execute code in doGet and not code in
    doPost() method. so in your first form use method as POST instead of keeping
    it to default i.e no method specified.
    let me know where are you using RequestDispatcher.
    //rohit

  • Request dispatcher vs redirect

    if there is the request dispatcher already,
              then what exactly is the point of having response.sendRedirect(url)
              is there any situation in which one should use sendRedirect over using the
              request dispatcher?
              thanks
              -Tao
              Tao Ge
              Software Engineer
              [email protected]
              (310) 883-1837
              NextEngine, Inc.
              401 Wilshire Blvd., Ninth Floor
              Santa Monica, California 90401
              This email is intended only for the use of the individual or entity to which
              it is addressed and contains information that is privileged and
              confidential. If the reader of this message is not the intended recipient
              or the employee or agent responsible for delivering the message to the
              intended recipient, you are hereby notified that any review, use, disclosure
              or distribution of this communication is strictly prohibited. If you have
              received this communication in error, please notify the sender immediately
              by reply email and destroy all copies of the original message.
              Thank you.
              

              1. You cannot forward to a file thats not this server. But you can use
              sendRedirect
              2. By using sendRedirect you are also informing browser regarding change of the
              location.
              3. When you post data to server and use of browser relaod posts data back to
              server in case of dispatcher.
              Thanks,
              Kumar.
              "Tao Y. Ge" wrote:
              > if there is the request dispatcher already,
              > then what exactly is the point of having response.sendRedirect(url)
              >
              > is there any situation in which one should use sendRedirect over using the
              > request dispatcher?
              >
              > thanks
              >
              > -Tao
              >
              > --
              >
              > Tao Ge
              > Software Engineer
              > [email protected]
              > (310) 883-1837
              >
              > NextEngine, Inc.
              > 401 Wilshire Blvd., Ninth Floor
              > Santa Monica, California 90401
              >
              > ---
              > This email is intended only for the use of the individual or entity to which
              > it is addressed and contains information that is privileged and
              > confidential. If the reader of this message is not the intended recipient
              > or the employee or agent responsible for delivering the message to the
              > intended recipient, you are hereby notified that any review, use, disclosure
              > or distribution of this communication is strictly prohibited. If you have
              > received this communication in error, please notify the sender immediately
              > by reply email and destroy all copies of the original message.
              > Thank you.
              

  • Can Request Dispatcher include 2 Jsp's ??

    HI ...
    can Request Dispatcher include 2 Jsp's.....in which
    second Jsp is accessing some parameters from First Jsp....
    From my point of view , both jsp's are get compiled seperately hence
    2nd Jsp is not getting parameters from 1st Jsp..
    Any other way to solve this problem....???
    rdTop = sc.getRequestDispatcher("/Reports/top.jsp");
    rdTop.include(req,res);
    rd1 = sc.getRequestDispatcher("/Reports/MenuTrail.jsp");
    rd1.include(req,res);
    Thanks

    No Actually ,i am using include becoz Top .jsp includes our menu,& menu trail also contains our menu...i am displaying both Jsp's thru
    servlet hence i have used Include.....
    Thanks

  • What is the best way to Process non-JSF request??

    I am engaged in new project using JSF.
    We came across the serious problem that there is no-way
    to let JSF execute action method of managed bean at the
    first request.
    That is because, JSF gets method binding information only
    from pre-displayed UIComponent, it seems impossible to
    let JSF know about the method binding info when they receive
    the request from external system, or from non-JSF pages i n the
    same system.
    I get to two ways to solve this problem.
    1. develop a custom-servlet
    The tasks of the custom servlet is,
    - receive a request from external system or non-JSF pages.
    - get managed bean and execute it's action method.
    - get next page info
    - dispatch to next page through FacesServlet
    2. use bridge-JSF page as a intermediation
    This is kind of last resort.
    As I described above, JSF can get method binding info, only
    from components of pre-displayed pages.
    So, I use bridge -JSF page to let it work as a intermediation.
    It displays nothing, just click the commandbutton automatica
    lly(by JavaScript).
    Of-cource, I prefer 1 to 2.
    Codes below are custom servlet sample , I made.
    Pls let me know if it's ok or not.
    thanks
    public class FESFacesServlet extends HttpServlet{
        public void doPost(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
    /* init process */
            LifecycleFactory lFactory = (LifecycleFactory)
                                            FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
            Lifecycle lifecycle = lFactory
                                    .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
            FacesContextFactory fcFactory = (FacesContextFactory)
                                                FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
            FacesContext facesContext = fcFactory.getFacesContext(getServletContext(), request, response,lifecycle);
            Application application = facesContext.getApplication();
    /* set from-view-id */
            ViewHandler viewHandler = application.getViewHandler();
            String viewId = request.getParameter("fromviewid");
            UIViewRoot view = viewHandler.createView(facesContext, viewId);
            facesContext.setViewRoot(view);
    /* find managed bean and execute it's action method */
            ManagedBeanBase managedBean = (ManagedBeanBase)application.getVariableResolver().
                                                    resolveVariable(facesContext, request.getParameter("command"));
            String outCome = managedBean.start();
    /* look for next page info */
            NavigationHandler navigationHandler = application.getNavigationHandler();
            navigationHandler.handleNavigation(facesContext, null, outCome);
    /* dispatch to next page throw FacesServlet */    
            facesContext.getExternalContext().dispatch("/faces" + facesContext.getViewRoot().getViewId());
            facesContext.release();
        public void doGet(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
            this.doPost(request,response);
    -

    the common approach is kind of like your number 2)
    but you dont need a commandButton
    just have your first page redirect to your start page
    e.g.
    index.html
    <html>
    <head>
    <!�redirect to startPage -->
    <meta http-equiv="Refresh" content= "0; URL=index.faces"/>
    <title>Start Web Application</title>
    </head>
    <body>
    <p>Please wait for the web application to start.</p>
    </body>
    </html>

  • Problem with using Request dispatcher in my login,jspx

    Hi
    I am using Jdev 11g and new to adf.
    I am trying to work with adf security.
    I designed a login.jspx page and loginproxy.jspx accoridng to the following link
    http://groundside.com/blog/DuncanMills.php?title=j2ee_security_a_jsf_based_login_form&more=1&c=1&tb=1&pb=1
    I have added this code in login.java
         ExternalContext ectx =    FacesContext.getCurrentInstance().getExternalContext();
         HttpServletRequest request =    (HttpServletRequest)ectx.getRequest();
         HttpServletResponse response =    (HttpServletResponse)ectx.getResponse();
         RequestDispatcher dispatcher =   request.getRequestDispatcher("loginnew.jspx");
    RequestDispatcher dispatcher =   request.getRequestDispatcher("j_security_check");
        request.setAttribute("j_username", username);
        request.setAttribute("j_password", password);
         dispatcher.forward(request,response);
    When it tries to execute dispatch statement, it goes in an infinite loop and finally gets me a stack overflow error and also in the cosole it prints series of exceptions like
    ActionListenerImpl><processAction> javax.servlet.ServletException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class oracle.adf.controller.ControllerException
    javax.faces.el.EvaluationException: javax.servlet.ServletException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class oracle.adf.controller.ControllerExceptionI have to validate the user against database hence i created a login.jspx with a backing bean so that i can access the username and password and validate the credentials against db and redirect user to the appropriate page.
    The functionality i want to implement is very simple but i just cant get it to work using adf security.
    any help is highly appreciated.
    thanks
    at

    Hi Pedja,
    Thanks for the prompt reply.
    I have been following the link you mentioned to create ADF security and successfully implementedthe first part where if i directly give any internal page url it redirects me back to login page.
    Instead of using weblogic-sql authenticator, i wanted to manually authenticate the user in loginbean.java where i check the username passowrd against the db.
    I had also implemented the method to access username,password mentioned in the following thread
    Re: ADF security on my jspx  page as login page
    Insted of using authentication.login, i am calling the db method to do the validation.
    The thing is after my db validation it does redirect me to the success page(menu.jspx). but when i click links on menu.jspx it redirects me back to login page.
    so i understand that user is not yet set in the session.
    I am stuck at the point how do i code the login.jspx, currently my login.jspx does not have any j_security_check and i think this is what is creating the problem.
    while searching for adding jsecurity in jspx i landed on the blog of 2006 and started using that.
    Can you please point me to some link which explains how to code login.jspx , i have been trying hard for couple of days.
    Thanks again
    ash

Maybe you are looking for

  • How do I show the details of a customer when they are logged in a secure zone?

    How do I show the details of a customer when they are logged in a secure zone? I want to show the customer details as well as some customer CRM fields that are applied to the customer. None of these are entered via a form, they would be entered by th

  • Desktop Site Not Loading Images or Accordian Menu

    I have exported my site files and uploaded them to my server in a folder and the Desktop version is not loading properly. There are a lot of pages, so I haven't reviewed them all just yet, but it appears that the mobile version is working fine. For t

  • Pricing or Tax Based on First letter of Batch

    Hi Guru I have a requirement  Tax or price  should be charged based on Batch  where batch starts with 'R' . then system has to charge  on that Batch  only  7 % Percent Tax or price. Could you please help how  to consider first letter of the Batch for

  • Quality info record

    Hi all, Is quality info record required if I want to block payment for a particular vendor based on the Usage Decision? Thanks and Regards, Raghu

  • Abap Code help in Extractor!!!

    Hi all I am not an abaper, I am using Bw 3.5; I need to write a code in "ZBSIS" and "ZBSAS" Extractor Include program ZXRSAU01: so that the report based on cube "ZBSISAS" shows values for field Transaction key "ZKTOSL". The field "KTOSL" is not activ