Multi response objects

I'm stuck in a servlet coding problem but I think that this is a common question programming a servlet and perhaps someone has any solution.
Problem:
1. html form to enter data. Button to submit the data to the servlet
2. servlet should convert the date and give and send a file back to the user (file requester opens in browser)
3. after saving the file / while saving the file the site should be redirected to the confirmation page
=> How can I handle the output to the file and the redirectin by the servlet??
Thanks a lot fpr any input to this problem.
chris

That is right. That is not possible due to the nature of HTTP protocol. When the file content is sent out, the response is committed. So, the server can not do redirect any more because the state is not right now.
However, it is possible to simulate the same user experience as you described (submit form, get the file, see the confirmation page) by embedding an invisible Applet or WebStart to do the file download. When the file download is done, the Applet or WebStart could instruct the browser to go to the confirmation page. Well, the Applet or WebStart has sufficient information to do the confirmation by itself. But to go to the confirmation page could keep the same look and feel user experience as well as save your time to design any GUI stuff for the Applet or WebStart.
By the way, the confirmation obtained by Applet or WebStart is the most reliable way to do the business because it won't confirm until the user actually gets the downloaded file. If something goes wrong during the file transmission, the Applet/WebStart could instruct the browser to go to the error handling page.

Similar Messages

  • Two response objects within one servlet...

    Heya guys, quite new to java and got stuck for the whole day on this.
    I need to combine two responses inside one servlet. One response retrieves picture from the database and it works fine. Another one retrieves text from database also works fine on its own. Second i try to use both end up with hundreds of exceptions.
    Any idea what to do, not how...but what???
    Thanks

    Compiling 1 source file to F:\gopal\weba\WebApplication6\build\web\WEB-INF\classes
    F:\gopal\weba\WebApplication6\src\java\NewServlet.java:48:
    processRequest(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletResponse) in NewServlet cannot be applied to (javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
    processRequest(request, response);
    F:\gopal\weba\WebApplication6\src\java\NewServlet.java:57: processRequest(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletResponse) in NewServlet cannot be applied to (javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
    processRequest(request, response);
    2 errors
    F:\gopal\weba\WebApplication6\nbproject\build-impl.xml:295: The following error occurred while executing this line:
    F:\gopal\weba\WebApplication6\nbproject\build-impl.xml:149: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 2 seconds)
    You cannot use two response object.

  • Response object in JSP Dyn page

    Hi SAP EP Gurus,
    I want to use response.setStatus() mehtod in jspdynpage but it is not working as expected. I am able to use other methods of response object like response.write().
    As per my knowledge if i set response.setStatus(200) is should send error to client but it is not seding error.
    It is working as same for both response.setStatus(200) and response.setStatus(500).
    Is there any special way to use response.setStatus() in portal? It is working as expected in normal jsp application.

    I tried but had no luck. Below is my JSPDYNPAGE code...
    <%@ page import="javax.servlet.http.HttpServletResponse" %>
    <%@ page import="com.sapportals.portal.prt.component.IPortalComponentRequest,com.sapportals.portal.prt.component.IPortalComponentResponse"%>
    <HTML>
         <head>
         </head>
         <body>
    <%
    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
    HttpServletResponse servletResponse = request.getServletResponse(true);esss
    servletResponse.setStatus(500);
    %>
              </body>
         </HTML>
    It is not working showing portal run time error

  • Is there a maximum number of "multi state objects" per article? Indesign keeps crashing

    Hi, i have 12 multi state objects on a page, and indesign keeps crashing.
    i know this seems like a high number, but I have done this to create a work around - ticker (like an old style airport board e.g. https://www.google.co.uk/search?q=airport+board&espv=2&biw=1306&bih=653&source=lnms&tbm=is ch&sa=X&ei=TkYUVb3ZJIb0PJ7DgZg… each set of 3 creating one graphic e.g. 3.35
    After creating these Indesign keeps crashing when i try to preview?
    Any advice would be appreciated.

    It sounds like you're running in to a memory problem: Memory Handling in DPS
    That said, usually multiple MSOs on the page don't usually cause memory problems because only the first state of the MSO is loaded into memory. If the first state of each MSO is loading a web overlay displaying ticker information, then that's the most likely culprit. Consider redesigning the page so that only a few tickers are loaded into memory and the user needs to tap to reveal additional tickers.

  • WebService response object in XML - parsing attributes

    Hi- new to Flex and I'm trying to parse out the attributes of the response object. I can get the entire object and see that its working, but I cant get just a single attribute. It pulls weather info for world cities. For example, I just want the location name and temperature.
    Any advice on this? Thanks!
    <?xml version="1.0"?>
    <!-- fds\rpc\RPCResultFaultMXML.mxml -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    xmlns:s="library://ns.adobe.com/flex/spark">
        <mx:Script>
            <![CDATA[
                import mx.rpc.soap.SOAPFault;        
                import mx.rpc.events.ResultEvent;
                import mx.rpc.events.FaultEvent;
                import mx.controls.Alert;
                import mx.utils.ObjectUtil;
                public function showErrorDialog(event:FaultEvent):void {
                    // Handle operation fault.
                    Alert.show(event.fault.faultString, "Error");
                public function defaultFault(event:FaultEvent):void {
                    // Handle service fault.
                    if (event.fault is SOAPFault) {
                        var fault:SOAPFault=event.fault as SOAPFault;
                        var faultElement:XML=fault.element;
                        // You could use E4X to traverse the raw fault element returned in the SOAP envelope.
                    Alert.show(event.fault.faultString, "Error");              
                public function log(event:ResultEvent):void {
                    // Handle result.
                    trace(event.result);
                    //trace(ObjectUtil.toString(event.result));
                    //var len:int;
                    //len = event.result.length;
                    //trace(len);
                    //trace(event.result);
                    //trace(event.result.GetWeatherResponse.Location);
                    //var myXML:XML = new XML(event.result);
                    //trace(myXML.attribute("Location"));
            ]]>
        </mx:Script>
        <mx:WebService id="WeatherService" wsdl="http://www.webservicex.com/globalweather.asmx?wsdl"
                       fault="defaultFault(event)">
            <mx:operation name="GetWeather"
                          fault="showErrorDialog(event)"
                          result="log(event)"
                          resultFormat="xml">
                <mx:request>
                    <CityName>{myCity.text}</CityName>
                    <CountryName>{myCountry.text}</CountryName>
                </mx:request>
            </mx:operation>
        </mx:WebService>
        <mx:TextInput id="myCity" text="Madrid"/>
        <mx:TextInput id="myCountry" text="Spain"/>
        <!-- Call the web service operation with a Button click. -->
        <mx:Button width="60" label="Get Weather"
                  click="WeatherService.GetWeather.send();"/>
        <!-- Display the Weather -->
        <mx:Label text="Weather:"/>
        <mx:TextArea text="{WeatherService.GetWeather.lastResult}" height="200"/>
    </mx:Application>

    The WSDL says GetWeatherResponse is a string, and it appears to be a string of XML, so set <mx:operation resultFormat="object"> as this will unwrap the SOAP response value and leave a string typed value intact. You can then create a new ActionScript 3.0 E4X-based XML instance from the unwrapped string:
        var myXML:XML = new XML(event.result.toString());
    You can then travese the XML document using E4X syntax, a simple example is included below:
        trace(myXML..Location);
        trace(myXML..Temperature);

  • Can I assign the text in a multi-state object?

    I want to assign InCopy files to the captions that are part of a slideshow, but I can't seem to create assignments for the text boxes that are in a multi-state object. Is this possible?

    Currently there is no capability to add text frames withing an MSO to an InCopy assignment. There is limited support for this edit workflow when using solutions such as WoodWing or K4. Please make sure to fill out the feature request form: https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform so that we can capture the demand for this function.

  • Error with response object in Portal Application Module

    Hi,
    i have a portal application project in NWDS, with a JspDynpage component. I have a jsp that contains this code:
    OutputStream os = componentResponse.getServletResponse().getOutputStream();
    response.addHeader("Content-Disposition", "attachment;filename=" + sTITLE +".pdf");
    response.setContentType("application/pdf");
    os.write(contenido);
    os.close();
    this code open a pdf in new window. In web module project that app runs correctly but in portal application no, it fails in object response. the log (in default trace) doesn´t help me nothing, only sais:
    Jun 6, 2011 3:19:55 PM     com.sap.portal.prt.runtime.servlet_jsp [SAPEngine_Application_Thread[impl:3]_13] Error: >>> JSPCompiler >>> ERROR in Compiling :JSPFileInfo :314221189
    JSP File : /usr/sap/DP4/DVEBMGS40/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/web-inf/portal/portalapps/appl.factdist.efact.por/pagelet/inicio.jsp
    Class Name: sapportalsjspInicio
    Java File : /usr/sap/DP4/DVEBMGS40/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/web-inf/portal/portalapps/appl.factdist.efact.por/work/pagelet/_sapportalsjsp_inicio.java
    Package Name : pagelet
    Class File : /usr/sap/DP4/DVEBMGS40/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/web-inf/portal/portalapps/appl.factdist.efact.por/work/pagelet/_sapportalsjsp_inicio.class
    Is out dated : false [email protected]bbc2b
    In addition, i can use the request object perfectly
    somebody knows what's happening??
    Thank you,
    Fernando

    Hi,
    You shouldn't use the response object directly
    Instead, create a new HttpServletResponse reference from the componentRequest object.
    Try using the following:
    long length = file.length(); // where 'file' is a File() object of your sTITLE +".pdf" file
    // Create the byte array to hold the data
    byte[] bytes = new byte[(int)length];
    int offset = 0;
    int numRead = 0;
    while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
        offset += numRead;
    //The most important part:
    HttpServletResponse res = componentRequest.getServletResponse(true);
    res.setContentType("application/pdf");
    res.addHeader("Content-Disposition", "attachment;filename=" + sTITLE +".pdf");
    res.getOutputStream().write(bytes);

  • My multi-state object disappear's when I export to PDF but works in Preview mode?

    I created a multi-state object which is a series of logos that appear when a button is clicked. There are two buttons one is set to go the the previous state and one is set to go to the next state. When I view it in the preview mode it works fine but when I export it to PDF nothing happens when I click the buttons. Any help would be greatly appreciated.

    Multi-state objects are NOT supported in PDF. The PDF standard preceded the development of multi-state objects. It's now under the control of the ISO so may be slow to adapt.
    They work when exporting to SWF or with the Adobe Digital Publishing Suite.

  • Hyperlinks in Multi-state object?

    I can't find the answer in the Help PDF, maybe because it is maybe even impossible to achieve it... or maybe there is a trick...
    How can I make hyperlinks to work in a Multi-state object?
    Thank you

    Wait a few days for the release 18 tools.

  • Image buttons in multi-state-object

    Hello,
    I created 3 articles in Indesign for the iPad. The 3 articles come in a liquid format (landscape and portrait) and are all quite picture heavy. Nevertheless, I am very surprised of the folio file size, it's over 500 MB big.
    The biggest Indesign file of these 3 articles has 115 MB as there are many statuses (multi-state-objects) (please see screenshots attached). I checked these resources out: Digital Publishing Suite Help | Best practices for creating overlays and Structuring Files for DPS
    According to these resources, the images in my 9 big circles should be resampled when I export the folio in PDF format. So by theory the image sizes cannot be the problem here. But what else can be the problem? I can't think of any other issues.
    What can I do to reduce the folio size. Please help!

    I don't have any web overlays, no. Just normal URL links (In-App-Browser opens). I have 1 video file embedded (nearly 400 MB), so I am well aware of that. But 150 MB for the rest when it's only 3 articles (despite having 2 formats) seems a bit too much to me. I did add the articles to the folio once at a time, yes. And it is the article with the many buttons and MSOs (as seen in the screenshots above) that is so big. This is also the article with the video in it, but still. I have the feeling buttons or the images in the buttons are making the folio so big. I often do app magazines with approx. 15 articles and 3-4 videos embedded (200-300 MB per video!) and that is normally 650 MB or so. So comparing that with my 3 articles makes me wonder.
    Do MSOs and buttons make a folio big, is that possible? Or is it the images in the 9 big buttons not being resampled correctly (even though the documentation - 2 links in my original post - say something else). When I export the article, I always export it as PDF and when looking at the loading bar, it says "saving as PNG". So that should mean that all my buttons are resampled, I don't have to worry about image file size and it's exported as PNG in the PDF. Hm...

  • HTTP request/response object not thread safe.

    According to the serlvet spec. Http Request/Response
    are not thread safe. Quoting from the Spec:
    " Implementations of the request and response objects are not guaranteed to be thread safe. This means that they should only be used within the scope of the request handling thread. References to the request and response objects must not be given to objects executing in other threads as the resulting behavior may be nondeterministic."
    This has prompt me to ask the following question.
    For Example I have a servlet which does the following
    request.setAttribute("myVar","Hello");
    The request and response is dispatched(using RequestDispatch.include(request,response)) to another
    servlet which retrieve this attribute i.e request.getAttribute("myVar");
    Is this safe?
    The Spec only said "The Container Provider must ensure that the dispatch of the request to a target
    servlet occurs in the same thread of the same VM as the original request." I take this meaning that the targeting servlet does not have to run in the same thread(only dispatch), otherwise it would be safe.

    To put it another way, you can only have onle thing working on a request at a time. For instance, the ServletContext is available to all servlets running on a server. If you tried to save a particular request to the ServletContext, it would potentially be available to many concurrently running servlets. They could all change whatever in it at the same time. Each servlet is in its own running thread. Hope that helps some.

  • Web service response object contains no values

    Hi,
    Using Netweaver, I've created an EJB-based web service that contains a single method. The method takes two input parameters and returns as a response, a data transfer object (DTO) containing several boolean values.  When I test this web service with the Web Service Navigator however, the response object contains a flat DTO-- meaning the contents of the DTO are missing. For example, this is what happens now when I call the web
    service...
    Incoming parameters:
    ...userID (String) = some user ID
    ...systemID (String) = some system ID
    Outgoing parameters:
    ...response
    ......(nothing contained within response--
    ...... there should be boolean values here)
    But this is what I should see when I call the web service...
    Incoming parameters:
    ...userID (String) = some user ID
    ...systemID (String) = some system ID
    Outgoing parameters:
    ...response
    ......booleanValue1
    ......booleanValue2
    ......booleanValue3
    Documentation doesn't seem to address this problem. Does anyone know how to correct this?
    Thanks,
    Amy

    Hi
    Have you found the workaround?
    Sorry for refreshing topic. Flag mustUnderstand ='1' in response is unussual thing.
    BR

  • Does any one implemented solution for httpservlet request/response object in IWSDLInterceptor implemented class?

    I am trying to handle Producer not available situation in which I am using Interceptor IWSDLInterceptor in WLP 10.3.4. I am able to retrieve exception using onWSDLException but from here if I have to forward my pageURL object I need httpservlet request and response. I tried my own filter class to have its own customize request and also tried it out all other Interceptor to see if any one can handle IOException. I did manage to throw my own Customize exception but  that also did not work out as Page does not have any backing file or any supportive Controller class.
    Does any one implemented solution for httpservlet request/response object in IWSDLInterceptor implemented class? or do we have any specific documentation in regards to this? As I am not able to find much martial on IWSDLInterceptor except Java API from Oracle and article defining Two way SSL handshake Producer.
    Any kind of help is appreciated.
    Thanks
    PT

    Thanks Emmanuel for your response but render behavior is not available for IWSDLRequestContext/IWDSLResponseContext object which IWSDLInterceptor uses for implementation.
    Let me put my question in little simpler manner. May be my approach to the problem is not proper.
    Problem : Handle Producer Not available (no application exists on server) on consumer side.
    So far tried approach : Producer is not running then I am able to handle that TransportException at IInitCookieInterceptor/IHandleEventInterceptor onFault behaviour but in the case of Producer not even exists Consumer try to get WSDL fetch operation and failed with FileNotFoundException.
    To handle this exception, I used IWSDLInterceptor which is available under IWSDLInterceptor.OnWSDLException (Oracle Fusion Middleware Java API for Oracle WebLogic Portal)
    I am able to catch the exception but problem arise when application needs to forward at specific page/render portlet for this situation. For that it required request/response object but IWSDLInterceptor does not give any kind of instances to redirect request as there is no direct access to HTTPServlet request/response object.
    I tried my custom request object to use there. I tried out custom filter object of IWSDLrequestContext. nothing works.
    One approach works is to put producer WSDL file at consumer level. But in that, you need to handle different producer files for different environment. Which I don't think its a good approach.
    eAny one Let me know if my approach to the problem/scenario is wrong. Or if I am missing out any other supporting interface which also required to handle this scenario. or I am using wrong interface for this scenario.
    Thanks for your help in advance.
    PT.

  • URGENT! Can response object contain text as well as binary data

    hi all,
    My test scneario is like this..
    a) User is having a button "Download File" i will call this as download.jsp
    b) After hitting the download button i will be sending the file to user by writting into the ServletOutputSream.
    c) Whatever option user chooses (i.e. Save / Open / Cancel) I want to do some updations on the existing user screen.
    Maybe presenting him the download status e.g. "File Downloaded"
    The problems i am facing are
    1. SInce i am using ServletOutputSream once i flush the stream i loose the control on response object.
    2. After user's operation (i.e. Save / Open / Cancel) unless user again hits
    something on UI my server has to look at him with dumb eyes. :(
    3.The download operation that i am performing expects some attributes from the request ..
    they are Object attributes and not string attribute so i cant user URL rewritting.
    If anybody has encountered this type of problem in there projects please share the workaround you used.
    Thanx a lot
    --Bhupendra Mahajan

    Here in order to send the file to Client i must use Stream ... and in prder to
    update the status i.e. HTML i must use Printwritter.... That is the reason
    i need both ... If you have some OutputStream available deep down somewhere you can use
    both; it just takes a bit of discipline:OutputStream ros; // available from somewhere
    // use the following stream for your binary output:
    BufferedOutputStream bos= new BufferedOutputStream(ros);
    // and use this one for your PrintWriter:
    PrintWriter pw= new PrintWriter(bos);Everytime before you want to print some binary data, flush the pw, and everytime
    before you want to print some text data, flush the bos.
    kind regards,
    Jos

  • Slideshow Using Multi-State Objects

    Hi,
    I created a slideshow in an Indesign document using multi-state objects. The slideshow has foward and backward buttons to navigate the slideshow. The slideshow works fine in Indesign but when I export the document as an intereactive pdf, the slideshow no longers works. What am I doing wrong? I'm using Indesign CS 5.5.
    Thank you,
    Kristie

    What you're doing wrong is expecting it to work. MSOs are for SWF and DPS output only.
    The only workaround is doing it in its own file, exporting to SWF and placing that in the PDF.
    Bob

Maybe you are looking for

  • HP PhotoSmart Premium C310 - Windows 8 and Office 2013 - Where have the page sizes gone

    I have just upgraded to Office 2013 on my windows 8 PC. Now when I goto print, and click "printer properties" evert drop down is blank, and all the titles are in Chinese. HELP please. Also the page size options have now lost useful things like A4, Le

  • Saving compound graphics in structured documents OR how to create a link in a graphic

    Hi all, Frame 9 structured. We need to make a graphic icon into a link.  In nonstructured documents (we have a different product that is not in structure), we just create a text frame on top of the graphic in the anchored frame, and add a hypertext m

  • Erase, Sync, Fail.

    It seems that I am unable to trI try to update the library on my sister's iPod (nano 3G) by erasing and syncing her device with the most current library located on my laptop (Windows 7), and I now have an empty device that won't sync. Help!

  • LMS 3.1 Device Update problem through CCO

    If I use the correct CCO password, I get "Connection to Cisco.com failed. Please check log files. Download operation cannot proceed." All I see in psu.log is "FATAL  [DevUpdate : performAdd]  : Error while trying to connect to Cisco.com. Return Code

  • KANBAN to Purchase Requisition?

    Hello- I am researching the possibility of creating Purchase Requisition from KANBANs (PK13n).  I have seen a couple posts of people discussing a similar requirement, but I can't seem to find any detail as to whether or not this is a possible.  Any i