Controller Is Being Called Twice - Why???

I think this is going to be a complicated question to answer but I'll try to explain what's going on as best I can. The basic problem I'm having is that the controller class gets called twice for some reason (instead of once) and I have no idea why. I type in a URL in my browser that goes to a JSP page called �myJsp.jsp�. Basically all that page contains is this...
<tiles:insert definition =�my.tile� flush=�true�/>In my tiles-defs.xml file I have the following listing...<definition
name="my.tile"
path="SomeOtherJsp.jsp"
controllerClass="x.y.z.MyController">
</definition>
x.y.z.MyController.java makes some calls to a DAO to retrieve data. MyController.java then puts that data into the requestScope for the JSP below to access...
SomeOtherJsp.jsp has nothing special in it although it DOES contain a link to myJsp.jsp (and, somehow, it's like this link is being clicked even though I'm not clicking it).
<a href="myJsp.jsp?someParam=<c:out value="${requestScope.someValue}"/>">Click Here To Do Something</a>If anyone can help I'd greatly appreciate it. By the way, I spoke to someone else who mentioned that I should turn this kind of thing into a struts action instead of doing a deletion within a controller class. I am going to refactor my code to do this. However, I'm still curious to know the answer to my question. Maybe it will help me get a better understanding of exactly what's going on in the world of servlets. :)

Hi Shiv, <br><br>
Yes I have placed System.out.println...and a debug point ...<br>
super.processRequest(pageContext, webBean);<br>
OAApplicationModule am = pageContext.getApplicationModule(webBean); <br>
// String personId="13477";<br>
// Serializable[] parameters = { personId };<br>
if (!pageContext.isFormSubmission()) {     <br>
am.invokeMethod("createEmployeeRow", null);<br>
}<br>
//am.invokeMethod("initDetails",parameters);<br>
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!IN Process Request"); <br>
debug point is at String personID="13477"....<br><br>
Thanks<br>Soujanya

Similar Messages

  • Getter method being called twice

    Hi All,
    I have a h:inputText which updates a h:dataTable as soon as the user types something into it (through the use of Ajax4JSF's a4j:support element). In this way I have something similar to a suggestionbox, but which modifies the table underneath rather than displaying a dropdownlist with possible values. My problem is that for some reason the getter method in the managed request-scoped bean to which the h:dataTable is bound, is being called twice everytime a letter is typed into the h:inputText. The first call seems to happen directly after the bean has been constructed, as the value to which the h:inputText is bound is still empty, and the second call after that, but with the correct value obtained from the h:inputText.
    I searched the forums and found posts detailing similar problems, but I couldn't find an explanation of why it happens or a way to get rid of it. The common consensus seems to be to not have any processing intensive operations in the getter and to just accept that it will be called twice.
    Is there really no way around this?
    Thank you,
    Ristretto

    This is just the default behaviour of the JSF lifecycle. The first call checks if there is a default value or a value which is been set in the previous request. The second call gets the newly set value for display which is been set during the request processing. A way to get rid of the first call might be writing your own lifecycle implementation.

  • Servlet doPost being called twice

    Hello all,
    I have a servlet that is being called twice. The servlet is used to direct the user to the next jsp. I have 4 JSPs that the user steps through to add a record to a database. The 1st JSP lists the records that they have and asks them to add, edit or delete. The servlet gets call to direct them to the next JSP that they enter the data (or update) on. It then calls a verification JSP so the user can verify the information before submitting it. If everything is fine they submit the data. This verification JSP calls the servlet that adds or updates the record in the database. The servlet then directs the user to a confirmation page that tells the user if the submit was successful or not.
    Here is how the flow is:
    servlet -->menu.jsp -->servlet -->add.jsp -->verification.jsp -->servlet -->confirmation.jsp
    Everything is fine until the verification.jsp submits to the servlet. That's where the doPost gets called twice.
    I have put System.outs in the servlet code to see how many times the doPost gets called. It gets called once for every JSP except the verification JSP. When the user submits the data, the servlet's doPost gets called twice therefore it tries to add the record twice.
    Has anyone had this problem before? How do I fix it?
    Any help would be greatly appreciated!!
    Tracey

    Here is the output of the JSP that when submitted, calls the doPost twice:
    <HTML>
    <HEAD>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <TITLE>PreaPaid Legal Banner Verification</TITLE>
    <script language="javascript">
    function new_window(url){
    link = window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width=650,height=450,left=50,top=50");
    </script>
    </HEAD>
    <BODY>
    <form name="myForm" action="/webapp/BannerTracker/BannerTrackingServlet" method="post">
    <H3><font face="Arial">Banner Tracking Verification</font></H3>
    <table BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=2 WIDTH=500><tr><td>
    <font face="Arial" size=2>Below are the choices that you made for your image, size of the image and page to direct people to
    when they click on your banner.
    <br><br>If this is not what you would like, click the "Back" button to return to the Banner Selection page.
    <br><br>You can click on the page link to view a sample of the age you have choosen.
    </font></td></tr></table>
    <P>
    <font face="Arial" size=2>
    <input type="hidden" name="cmd" value="doadd">
    <input type="hidden" name="banname" value="yahoo">
    <input type="hidden" name="banlogin" value="test">
    <input type="hidden" name="banid" value="1">
    <input type="hidden" name="bangname" value="difference">
    <input type="hidden" name="bangsize" value="468x60">
    <input type="hidden" name="banpage" value="go/test?:home">
    <input type="hidden" name="session" value="PPL2P6LcONLiT45pSszZEb1GJ4HvRc5jQMDNPM8wCJ0rCZesD38oEZ4mC3KvCp8mDp00">
    <input type="hidden" name="bangtype" value="gif">
    <input type="hidden" name="banurl" value="<A HREF="http://www.prepaidlegal.com/go/test?banid=1&Assoc=test"><img src="http://www.prepaidlegal.com/html/buttonsdifference468x60.gif" border=0></A>">
    <br><b>Banner name: </b>yahoo
    <br><br><b>Page to be directed: </b>Your PPL Home Page
    <br><br><b>Image selected: </b><img src=/html/buttons/difference468x60.gif >
    <br><br><b>Copy the URL below to the banner source code.</b>
    <br><br><img src="http://www.prepaidlegal.com/html/buttonsdifference468x60.gif " border=0>
    </font>
    <br><br>
    <a><img src="/html/buttons/track_back.gif" border=0 onClick="window.history.back();"></a>
    <input type=image src="/html/buttons/track_continue.gif" border=0 onClick="javascript:document.myForm.submit();">
    </form>
    </BODY>
    </HTML>
    Here is the doPost code from my servlet:
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    System.out.println("doPost called");
    String next = "";
    try
    Command cmd = lookupCommand(req.getParameter("cmd"));
    next = cmd.execute(req);
    } catch (CommandException ce) {
    req.setAttribute("javax.servlet.jsp.jspException", ce);
    next = error;
    } catch (SQLException se) {
    req.setAttribute("javax.servlet.jsp.jspException", se);
    next = error;
    HttpSession mysession = req.getSession(true);
    String session = String.valueOf(mysession.getAttribute("storedSession"));
    if (session.equalsIgnoreCase("null"))
    session = req.getParameter("session");
    try
    checkSession(session);
    } catch (IOException ioe) {
    System.err.println("Session exception: " + ioe.getMessage() + ".");
    next = expire;
    } else {
    try
    checkSession(session);
    } catch (IOException ioe) {
    System.err.println("Session exception: " + ioe.getMessage() + ".");
    next = expire;
    if ( session != null )
    mysession.setAttribute("storedSession", session);
    RequestDispatcher rd;
    rd = getServletContext().getRequestDispatcher(jspdir + next);
    rd.forward(req, res);
    </code>
    I hope this helps.
    Tracey

  • Graphing: RollOverBoxItemRenderer being called twice

    i have an mx:AreaSeries, and an mx:LineSeries, and an
    itemRenderer in the mx:LineSeries, but for some reason, the
    RollOverBoxItemRenderer is being called on both the AreaSeries and
    the LineSeries - even though it's only in the LineSeries. any ideas
    as to why??

    i have an mx:AreaSeries, and an mx:LineSeries, and an
    itemRenderer in the mx:LineSeries, but for some reason, the
    RollOverBoxItemRenderer is being called on both the AreaSeries and
    the LineSeries - even though it's only in the LineSeries. any ideas
    as to why??

  • ProcessAction for portlet being called twice

    I am creating jsr-168 portlets on sun studio 8 . the problem that i am facing is that ProcessAction method seems to be called twice. Yet when i actually deploy the portlet on sun portal server 6 . They run well (i.e the method is called only once) . Can any body explain this? is this a bug or some configuration error at my development simulation server ? please help.
    regards
    Kimi

    This is a known bug indeed. If I'm not mistaken a fix for it was released as part of Update Pack 3 for JSE 8. Please check whether the update is available on the Update Center. Tools->Update Center

  • NeedHelp -- Process Request is being called twice ?

    Hi,<br>
    Process Request is called twice and row is intialized twice and row is inserting twice in table....<br>
    Thanks<br>
    soujanya

    Hi Shiv, <br><br>
    Yes I have placed System.out.println...and a debug point ...<br>
    super.processRequest(pageContext, webBean);<br>
    OAApplicationModule am = pageContext.getApplicationModule(webBean); <br>
    // String personId="13477";<br>
    // Serializable[] parameters = { personId };<br>
    if (!pageContext.isFormSubmission()) {     <br>
    am.invokeMethod("createEmployeeRow", null);<br>
    }<br>
    //am.invokeMethod("initDetails",parameters);<br>
    System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!IN Process Request"); <br>
    debug point is at String personID="13477"....<br><br>
    Thanks<br>Soujanya

  • Base page button submit causing Lov Controller procesRequest being called

    Hello,
    I have created programmatic LOV's to my base page to which I set to declarative LOV region.
    I run my page, provide value to one of the LOV and trigger LOV page open, select value and the value gets populated to my base page LOV item.
    Now I click submit button which should actually go to my base page CO, however it is going to the LOV Controller.
    and as expected my code in LOV CO which should not be called, at this point is called causing errors.
    This happens as the LOV items are set validation to true by default in OAF. If Is set the lovItemBean.setUnvalidated(false) to my Lov Item in my bas page CO and then run, my base page submit goes to its correct CO.
    Its clear the OAF is trying to validate the values of LOV in base page by calling LOV Controller.
    Is it a bug?
    Please help.
    Edited by: Prashanth Pillai on Aug 13, 2009 4:31 AM

    Hi,
    Whenever a form submit occurs on the page it checks for Client Side Validations.
    These should be enabled as it submits the form only when the validation succeds.
    So you should use
    lovItemBean.setUnvalidated(false);
    in the code
    Thanks,
    Gaurav

  • DoGet called twice on Tomcat Startup

    Hi,
    I have a problem with my Servlet doGet/doPost method being called twice (sometimes three times) on Tomcat 5 startup with J2SE 1.4 and Java SE 6. This problem happens on both, Firefox and Internet Explorer.
    I only have one Servlet (called ServletFrontController) in my descriptor, since I decided to use the Front Controller Pattern. This Servlet extends from a "base Servlet" which has all the init configurations. My deployment descriptor looks like this (I also have mappings which I haven't included here):
        <servlet>
            <servlet-name>MainServlet</servlet-name>
            <servlet-class>com.myprogram.ServletFrontController</servlet-class>
            <init-param>
                <param-name>config</param-name>
                <param-value>application.properties</param-value>
            </init-param>
        </servlet>My doGet / doPost / doHead methods from the base Servlet just delegate to the ServletFrontController "main" method, like this:
    public final void doGet(HttpServletRequest request, HttpServletResponse response) {
            try {
                process(request, response);
            } catch (Exception e) {
                handleException(e, request, response);
    }Does anyone had this problem and know why this could happen?
    Martin

    All,
    See post: [http://forum.java.sun.com/thread.jspa?threadID=720175|http://forum.java.sun.com/thread.jspa?threadID=720175]
    Might help.
    - JFK

  • EJB 3.1 @Singleton with @Startup causes @PostConstruct to be called twice...

    I have been working on initializing a some elements in the @PostConstruct annotated method within an EJB that is already annotated as @Singleton.  I decided that I wanted the initialization to be done when the EJB is deployed so I added the @Startup.  Both the constructor and @PostConstruct method is getting called twice.  Can someone please explain to me why it appears the EJB is being initialized twice and if there is a way to prevent the @PostConstruct method from being called twice?
    Many thanks,
    - Joe

    Is this with GlassFish?

  • EjbLoad called twice

    Hello, here is my stack trace:
    Called ExampleSessionEJBBean.getContactUsingContactId
    [ejbFindByPrimaryKey] - finding
    [ejbActivate] - activating gov.ons.ness.data.entitybeans.ContactEntityEJBBean@1d22
    [ejbPassivate] - passivating gov.ons.ness.data.entitybeans.ContactEntityEJBBean@1d22
    back in SessionBean
    [ejbActivate] - activating gov.ons.ness.data.entitybeans.ContactEntityEJBBean@1d22
    [ejbLoad] - loading gov.ons.ness.data.entitybeans.ContactEntityEJBBean@1d22
    [ejbLoad] - loading gov.ons.ness.data.entitybeans.ContactEntityEJBBean@1d22
    in business method (does a getName())
    [ejbStore] - storing
    [ejbPassivate] - passivating gov.ons.ness.data.entitybeans.ContactEntityEJBBean@1d22
    As you can see load is invoked twice before the business method.
    iIam accessing the BMP EJB via a session bean. I invoke findByPrimaryKey and then a business method on the entity bean. It all works ok, but i was curious to as why load is invoked twice? I thought the pattern was load-business-store?
    I also considered the fact the the finder method would call Load immediatley after executing but my trace statements from the session bean show that load is being called twice just before the business method is invoked.
    I am running JDev 9.03 using the buil in oc4j app server.
    cheers.

    sorry,
    seems to only invoke load twice the first time the business method is invoked. Subsequent invocations only call load once. Must be JDev, but does anyone know why?
    cheers.

  • Smw3_validation_execute called twice during initial download

    Hi All
    When trying to download a request for CUSTOMER_MAIN am facing some troubles in custom FM written. I reprocessed the error BDoc and in debugging mode i was able to find this function module smw3_validation_execute is being called twice for BDoc. This FM smw3_validation_execute is directly called from middleware adapter, if am not wrong.
    Is there any settings that i need to correct / check in adapter object CUSTOMER_MAIN or else some middleware settings needs to be validated?
    Did any one come across such an issue before?
    Thanks
    Karthik

    Hi,
       While re-processing a Bdoc in the message flow, if it needs to be rolled back due to a Abort status, the validation service is called for a second time.
    That is why, you find the smw3_validation_execute FM being called twice!
    Please check
    cl_smw_mflow=>__validate
    calling 
    cl_smw_mflow=>__validate_
    twice.
    smw3_validation_execute
    is called finally by 
    cl_smw_mflow=>__validate_
    Please reward if helpful.
    Thanks,
    Sudipta.

  • Parsing code called twice

    Somehow my code is being called twice with the result that everything has the same name twice (multiple names are legal according to the DTD).
    My parsing code looks like this:
    public Channel getChannel(Node channelnode)
    Channel channel;
    NodeList channelchildren;
    Element channelelement;
    channelelement = (Element)channelnode;
    if(channelelement.hasAttribute("id"))
    channel = new Channel(channelelement.getAttribute("id"));
    channelchildren = channelnode.getChildNodes();
    for(int i = 0 ; i < channelchildren.getLength() ; i++)
    if(channelchildren.item(i).getNodeType() == Node.ELEMENT_NODE)
    if(channelchildren.item(i).getNodeName().equals(("display-name")))
    channel.addDisplayname(getDisplayname(channelchildren.item(i)));
    if(channelchildren.item(i).getNodeName().equals(("icon")))
    if(channelchildren.item(i).getNodeName().equals(("url")))
    else
    channel = null;
    return channel;
    public String getDisplayname(Node displaynamenode)
    Element displaynameelement;
    Node displayname;
    displaynameelement = (Element)displaynamenode;
    displayname = displaynamenode.getFirstChild();
    if(displaynameelement.hasAttribute("lang"))
    return displayname.getNodeValue();
    else
    return displayname.getNodeValue();
    The code above is used to parse part of this tag in my XML file:
    <channel id="001.tv.tv2.dk">
    <display-name>TV 2</display-name>
    <icon src="http://tv.tv2.dk/images/logo/1.gif" />
    </channel>
    The problem is that the addDisplayname in the Channel class is somehow called twice even though there is only one <display-name> tag.
    Any help figuring out what is happening will be greatly appreciated.

    I know about the second point you are making. The if-then-else statement is actually the start of further development since the <display-name> element can have a lang attribute and I have to deal with it, but for now I ignore it since it is extremely rarely used and other things are more important.
    I had thought about the case that you mention with multiple calls of getChannel() but my debug output suggests that it is not the case. The method getChannel() returns a Channel object, which has a toString() method, and that object is given as argument to System.out.println() and never saved anywhere.
    The toString() method of the Channel object looks like this:
    public String toString()
    String tmp = new String();
    tmp += "display-name: " + displaynames.get(0);
    for(String name : displaynames)
    tmp += ", " + name;
    return tmp;
    With an output that look like this for the XML example given in my original post: display-name: TV 2, TV 2
    With this output I don't see how multiple calls of getChannel() can be the cause, since multiple calls should give multiple Channel objects and multiple lines of output.

  • EO Validation method called twice

    Hi,
    I have written an EO based field Validation method. But the problem is it is being called twice. First time ,it is validating correctly. But the second time it is not taking the field value and giving the error
    I have included it like this in my jspx.
    <af:inputText value="#{bindings.SubOrgName.inputValue}"
    label="#{bindings.SubOrgName.label}"
    required="#{bindings.SubOrgName.mandatory}"
    columns="#{bindings.SubOrgName.displayWidth}"
    binding="#{backing_Org.inputText3}"
    id="inputText3"
    rows="1">
    <af:validator binding="#{bindings.SubOrgName.validator}"/>
    </af:inputText>
    Please help.

    Thanks for sharing! ;-)

  • JavaScript Function Calls it is called twice only when add the component

    Hi,
    I am developing a SAP Design Studio Extension and I noticed that when I add the component on Application, SAP Design Studio calls the JavaScript SDK Functions twice only when I drag and drop the component.
    I found out about this just put an alert message in which JavaScript Function (init, beforeUpdate and afterUpdate).
    Is it ok to work this way?
    I am really curious if anyone else has come across this issue.
    Thank you,
    Fabio Almeida

    Hi Fabio,
    Yes, there does appear to be an issue with SDK component functions being called twice.  Mike Howles has implemented a workaround in this Toolbar example code. Refer to the code in the this.init function at the end.
    Regards,
    Mustafa.

  • Servlet Filters getting called twice

    Hi,
    I am debugging my way through a big project and I am noticing when a http requests comes in that some filters are being called twice.
    I checked the web.xml and nothing funny there and I have checked the respective doFilter() implementations and nothing unusual there.
    Any ideas?
    Thanks.

    Many reasons
    1. Filters are chained - the code in doFilter() upto the call to chain.doFilter() is executed before the request reaches the destined endpoint (servlet/jsp).
    Any code after the call to chain.doFilter() is executed after the endpoint (servlet/jsp) processes the request.
    2. When the response is a redirect, it would cause the browser to send a new request transparently to the end user. This new request would also hit the filter as would be expected.
    3. Filters can be used to intercept internal forwards and/or includes by indicating so in the web.xml. So when such an action happens a part of request processing, filters would be invoked.
    cheers,
    ram.

Maybe you are looking for

  • Two Questions Actually. Display & USB

    So I haven't even had my MacBook Pro 15" for a year and one of the USB ports seems to be completely unresponsive and I have no idea as to why. As such I have no idea what to do about it either? Second question is. I just bought a mini dvi to VGA adap

  • [Oracle to PostgreSQL]connction string lacks some options

    Hi guys, I want to connect from oracle 11g to PostgreSQL 9.3 . l get this error message: ORA-28500: connection from ORACLE to a non-Oracle system returned this message: [unixODBC]connction string lacks some options {08001,NativeErr = 202} ORA-02063:

  • Trouble Authoring DVD

    Hi, I am trying to author a DVD using Encore but whenever I go to Build DVD > Disc > Build and then attempt to actually build the disc, the program has trouble importing one of my video files. All of the settings are default but when I press "Build"

  • I can't set gmail on iPad

    I set up gmail on my ipad

  • Can only print 1st page of mulitple page document

    I know the fix for this but I was wondering if anyone figured out a way to deploy this.  My company has over 6000 computers and we are getting a ton of calls on this.   Please advise if anyone knows a way to deploy this or if there is a patch coming