MAKING TWO REQUESTS FROM A JSP AND HANDLING TWO RESPONSE ????????

Hi,
I have a requirement like below.
When a user clicks on download_pdf link on a web page, he should get the pdf data from the server where at the same time he should be shown with a processing window. Say the time taking for hitting the server and getting the response is 10 sec, the processing window should be shown for 10 sec and immediately it has to close.
My approach :
From JSP having download_pdf link :: while onClick I am calling an action which is nothing but a servlet call which will take care of getting the pdf data from the server and shown pdf save,cancel window. Other part is onClick I added a javascript function call which will open a seperate window (nothing but a jsp ) showing the processing icon.
The problem here is, I can not close the window immediately after we get the response from the servlet.
As we can not have direct communication between two responses(servlet reponse and processing window jsp) I am not able to close the window.
My trials to close the processing window JSP :
I tried to write a javascript in the processing window jsp which will be closed after 10 sec using setTimeout() funtion. But here the problem is the window will be closed after 10 sec where even if servlet call response takes 20 sec.
Please suggest me if I need to do any design change ?
Can I use any context attributes to come out of this ?
What would be the best design for this ?
Thanks and Regards,
V.Narayana.

Thanks for the idea.. I am trying to implement that.. Can you please let me know how Can I make a repetitive ajax call ??
If anyone interested in code, I am pasting all the sample files I prepared for..
start.jsp
===========================================================================================
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<script type="text/javascript">
function call(){
          w='550';
     h='240';
LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open("http://localhost:7001/SampleExportWeb/ExportServlet",'',settings);
function call2(){
          w='550';
     h='240';
LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open("http://localhost:7001/SampleExportWeb/statusWindow.jsp",'',settings);
setTimeout("win.close()",5000);
</script>
<input type="button" name="button" value="button" onclick="call();call2()">
</body>
</html>
=========================================================================================================
statusWindow.jsp
=============================================================================================================
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils"%>
<%@ page import = "com.bea.netuix.servlets.controls.portlet.PortletPresentationContext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<table border=1 width="100%">
<tr><td align="center" height="210">
<table border=1>
<tr><td align="center">
</td></tr>
</table>
</td></tr>
Narayana
<tr><td align="right">
<div class="buttonBar">
<div class="floatright">
     <a onClick="window.close();" class="button" title="" href="#">
<span>
</span>
</a>
</div>
</div><!-- end buttonBar -->
</td></tr>
<%
%>
<iframe id="exportCall" height="0px" width="0px"></iframe>
</table>
=============================================================================================================
FlowController.java
===============================================================================================================
package main.java.com.export.servlet;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Method;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
* Export Servlet will be invoked by all dashboard widgets to perform common
* functions (Print, Download, Export XLS/CSV)
* @author kadalur.r.supreeth
* @version 1.0
public class ExportServlet extends HttpServlet {
     public void service(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException {
          try {
               System.out.println("ExportServlet :: service: entered");
               Object exportManager = null;
               Class exportClass = null;
               Method invokingMethod = null;
               * This condition will be executed if requested operation is to
               * download PDF. Invoke the PDF converter method runtime and open
               * the window dialogue box with generated PDF file. The requested
               * operation value should be "pdfConverter".
               ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();
                    OutputStream ostreamPDF = resp.getOutputStream();
                    resp.setContentType("application/pdf");
                    resp.setHeader("Content-disposition", "attachment; filename="
                              + "downloadfile"
                              + ".pdf");
                    baosPDF.writeTo(ostreamPDF);
                    ostreamPDF.flush();
                    ostreamPDF.close();
          } catch (Exception e) {
               System.out.println(
                              "ExportServlet :: service method exception:"
                              + e.getMessage());
=========================================================================================================

Similar Messages

  • I bought an ipod in 2006 and used it only for a few days, and i lost it when it fell two times from my hand and it wasn`t working, help me regarding this.

    i bought an ipod in 2006 and used it only for a few days, and i lost it when it fell two times from my hand and it wasn`t working, help me regarding this.
    REGARDS
    RISHABH AULIYA

    Apple - Support - iPod - Repair pricing - http://www.apple.com/support/ipod/service/prices/
    ipod repair options - https://discussions.apple.com/thread/3900047 and https://discussions.apple.com/message/18867033
    Service Answer Center - iPod - http://support.apple.com/kb/index?page=servicefaq&geo=US&product=ipod  <-- enter correct country once on page.

  • Generate a runtime req xml from a jsp and then use existing idc webservice

    Hi,
    I need to write a jsp that will generate a runtime SOAP request xml intaking the paramters that I had put into the jsp and thereby take the response from the response xml , extract that and show that in a result.jsp
    I will be grateful if anybody can help to do this as I am not sure how I can generate the runtime xml and thereby use the existing Idc webservices.Please help!

    Hey,
    Did you get info or solution?

  • Need to read data from a jsp and insert in other jsp

    Hi,
    I have a jsp where i need to read from another jsp(which has data " header ---insert -----footer") and find a string "insert" in it and replace that string with a some value in the current jsp.
    Thanx in Advance.
    Sridhar.

    I have a jsp
    which needs to take headers and footers dynamically and insert them into my jsp.
    currently what i am doing is, using a script to get these header and footer and using document.write
    MYJSP.jsp looks this way
    <script src="/../Headerfooter.jsp"/>
    <script language="javascript">
    document.write(header); -->defined in -> /HeaderFooter.jsp
    document.write("<table>...</table>");
    document.write(footer);-->defined in -> /HeaderFooter.jsp
    </script>
    /HeaderFooter.jsp looks this way
    header = "<html>...<table width=\"100\">....";
    footer ="....</html">
    i dont want to use script bcoz i am getting problems in nestcape...

  • I transfered two pictures from downlands window and i have since the Iphoto window ...black with the small wheel on center..What's for solution ? in advance thanks.

    I have a Mac Book OS X. Yesterday i transferde two pictures from my dowland window to I Photo by simple sliding. Since that the I Photo window stay permenently black with in his center the small wheel ...And I can't open I photo...Have you please a solution ? Thanks in advance .

    What version of iPhoto? Assuming 09 or later:
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. .
    Regards
    TD

  • Take out multiple values from a db and handle them in an applet.

    I have a db with tables. I want to take out several values from them and make them visible in a JFrame (or applet).
    I dont know how to do. I have an app that connects to the db and selects the values and puts the Strings in a Vector. But now then?
    I have looked at examples that retrieve Strings but not vectors, isn't that possible?

    Hi,
    On initialization of your frame you can loop over your vector and display them.
    Now the problem is in what type of component do you want to put your data.
    I can give you an example.
    What you can do is create a String which will contain all the data from
    your vector and set that string to the component.
    Example:
    Vector data;
    String result;
    for(int i=0; i < data.size(); i++) {
    result += (String)data.elementAt(i) + "\n";
    Now you need to put the string into a component which is easy done.
    Let take a textarea component.
    JTextArea txaTest = new JTextArea();
    txtTest.setText(result);
    Now all the data will be shown in the textarea component on your frame.

  • My laptop is making weird noices from the back and i wanted to know if its normal or not

    Hello,
    I bought my laptop not to long ago and weird noices is coming oout from the back and I wanted to know if its normal for it to make those noices

    Weird noise coming from the back of the computer is not normal.
    Humming noise from fans and  sounds from working HD are normal.
    You can take the computer to the Apple store and have it checked out.
    Best.

  • I bought an audio book on iTunes and it charged me for two of the same book and downloaded two.  How do I get my money back for one of them?

    I purchased an audio book on iTunes store and was charged for two and downloaded two of the same book.  How do I get my money back for the second one?

    Try contacting iTunes support via this page : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption
    Note that audiobooks are currently a one-time only download from the store, so you may want to take a backup copy of it

  • Newbie"Making an Animation from static jpegs and inserting to CP

    If I have a series of photos of someone moving their hand from their waist to their head and back again, how easy is it to make a gif or swf that can be inserted into a Captivate (cp)slide?

    Hmm, well I would contend the first option is much better (but that's coming from someone who prefer's strongly typed languages).
    I'm not sure if what you're trying to do works with static variables, since I've never actually tried it, but if it did work, it would look something like this...
    happyBirthDayRects.push(R["HappyBirthDay000"+i]);
    Although you would need to add some logic to buffer the zeros correctly for any number larger than 9, which IMHO, is not an elegant solution at all. I actually think this would require more typing than the first solution (if you take autocompletion and copy/paste into account), not to mention the loss of type saftey.

  • Making My "Reel" from Assorted DVDs and VHSes

    Over the years, I've made a lot of films for National Geographic, Discovery and other companies, and usually I've gotten a VHS (in the old days) or a DVD (in the new) of the final show with credits, etc.
    What I'd like to do, in the simplest and cheapest way possible, is use Final Cut and DVD Studio Pro to make a professional reel of my work -- my greatest hits, as it were.
    What is the recommended method for getting both the admittedly crappy VHS material and the better DVD material into my computer in a format that allows me to import it into Final Cut?
    I do own a DVD recorder, if that helps. I realize that I'm going to have to record the VHS material onto a DVD to create a digital version of it. I'd like to know the exact work flow, how many pieces of software I will need to acquire, and why.
    Many thanks,
    PS

    I'm with Jim on this,
    if you worked on those shows, you should be able to get tx copies (full broadcast spec) copy them onto your preferred format (for showreels there is no reason to go above DV res really)
    rent a deck - I like and use sony J30, & DSR1800 both firewire connectable
    then have fun, only software you require is Humaneffort v6.07 and FC (but you knew that otherwise you wouldn't have posted)
    If you are stuck with VHS & DVD, mac the ripper or similar and a cheap A to D converter, its not going to look great though
    best to get those original masters I think
    good luck
    Andy

  • Passing data from Applet to JSP and back

    What is the best way for me to communicate between an Applet and a jsp page? I want to be able to call Applet methods from the JSP and be able to send data to the JSP from the Applet. Thanks.

    Can't do this
    JSP lives on the server. When it's done, the code is sent to the client
    So, in terms of lifespan...
    JSP -> Internet -> Client -> Applet
    JSP is dead before applet starts

  • Move change request from a maintenance project  to another project

    Hello all,
    we want to close a maintenance project A and create a new maintenance project B. We have a lot of change request they aren`t finish, so we want to move them to the new maintenance project.
    The following steps we have done:
    1. Doing all phases of the maintenance cycle of project A.
    2. Close maintenance cycle project A.
    3. Create a new project B.
    4. create a new maintenance cycle for project B.
    Now, we have the problem, that all change request from project A and maintenance cycle A didn't move to the new project B and cycle B.
    If you create a new maintenance cycle in project A, all open change requests move to the new cycle. But we want to move them to a new project and a new cycle.
    Have anybody a suggestion how to do this?
    Kind Regards
    Marc

    Hello Marc,
    there are a couple of methods in a class that might help you if you DO have to do it... but SAP will not support you in case you have any problem.
    you can take a look to methods of class CL_HF_HELPER.
    Methods :
    SET_BO_LINK_TO_CHNG_DOC is used to set link between SDMJ and SDMN
    SET_BO_TASKLIST_OF_CHNG_DOC is used to set link between SDMJ and tasklist 
    as there are those methods, to create links SAP, provides some others that are supposed to break them (If i remember well they are not activated or finished but you can still have a look !!)
    Those methods are
    DELETE_BO_LINK_OF_CHNG_DOC
    DELETE_BO_TASKLIST_OF_CHNG_DOC
    RECREATE_BO_LINK_OF_CHNG_DOC
    RECREATE_BO_TLIST_OF_CHNG_DOC
    Hope this helps
    One more time... be carefull with those methids... I think it s quite dangerous to handle those kind of things without SAP's support.
    Also, one mote thing... since many many customers have asked for this functionality; SAP is trying to develop the whole thing (with adjustments of Checks functionalites of ChaRM) for the next releases. Maybe that will be part of the next release
    Regards
    Khalil

  • How to retrieve the data from a jsp page for print?

    i have a dynamic jsp file which will get the data at runtime.I have a print button in the jsp.When i chick the print button it should capture the data from the jsp and print it as LANDSCAPE mode. Now i am using Java Api for this
              Following code is a working sample which prints some data in LANDSCAPE mode..This is working fine....How can i modify this to get the data from a jsp?....I am using weblogic workshop for development
              package Awtjava;
              //working example
              import java.awt.*;
              import java.awt.print.*;
              public class testPrint implements Printable {
              private static String s[];
              private static Font f;
              private static int nLines;
              public static void main (String arg[]){
              s = new String[10];
              f = new Font("Arial", Font.PLAIN, 11);
              int i;
              s[0] = "This is a printer test";
              for (i=1; i<10; i++){
              s[i] = "The next line";
              nLines = 10;
              testPrint.printa();
              public static void printa(){
              System.out.println("public static void printa () ");
              PrinterJob pj=PrinterJob.getPrinterJob();
              Book b = new Book();;
              PageFormat pf = new PageFormat();
              pf = pj.defaultPage(pf);
              b.append(new testPrint(), pf, 2);
              pj.setPageable (b);
              try{
              if (pj.printDialog()){
              pj.print();
              catch (Exception e) { System.out.println ("Error"); }
              public int print (Graphics g1, PageFormat pf, int n){
              System.out.println("public int print");
              int x,y,i,fa,fh;
              FontMetrics fm;
              Graphics2D g = (Graphics2D) g1;
              pf.setOrientation(PageFormat.LANDSCAPE);
              fm = g.getFontMetrics (f);
              fa = fm.getMaxAscent();
              fh = fm.getHeight();
              x = (int)pf.getImageableX();
              y = (int)pf.getImageableY() + fa;
              g.setFont (f);
              g.setColor(Color.black);
              if (n==1){
              for (i=0; i<10; i++){
              g.drawString (s, x, y);
              y += fh;
              return PAGE_EXISTS;
              else {
              for (i=10;i<10; i++){
              g.drawString (s[i], x, y);
              y += fh;
              return PAGE_EXISTS;
              Hope you will reply soon...
              Thanks in advance
              Maria

    Hey, I got a doubt that who will call the print method in the same program and what about the g.drawString() it is showing any output effect. Finally how the variable n will get initializing to 0 and 1 for two times respectively. Can u please elaborate on this...

  • How to capture the data from a JSP form

    Hi
    I have a JSP form, My task is to capture the data from a JSP and submit to Data Base. for example I have the field like
    Enter Table name to be created in data base: The table name is to be captured by a servlet and by that table name, table should be created in the data base.
    Edited by: Reddy_Prasad on ?? ?????, ???? ?:?? ???????
    Edited by: Reddy_Prasad on ?? ?????, ???? ?:?? ???????

    Get the entered value from the jsp into servlet using request.getParameter("enteredTableName"). it will return the String,pass this table name to execute query using JDBC connection and statement objects.
    -cheers Ram

  • Invoking BPEL Process from a JSP Page 500 Internal Server Error

    Hi,
    I try to invoke a BPEL Process from a JSP Page and receive the following error. I just pasted the example from the Oracle PM Developer's Guide tutorial. Previously I deployed the CreditRatingService BPEL Process.
    Can anyone help me, please?
    D.
    Here is a sequence from my JSP / and the error I get:
    String ssn = request.getParameter("ssn");
    if(ssn == null)
    ssn = "123-12-1234";
    String xml = "<ssn xmlns=\"http://services.otn.com\">"
    + ssn + "</ssn>";
    Locator locator = new Locator("default","welcome1");
    IDeliveryService deliveryService =
    (IDeliveryService)locator.lookupService
    (IDeliveryService.SERVICE_NAME );
    // construct the normalized message and send to oracle bpel process manager
    NormalizedMessage nm = new NormalizedMessage( );
    nm.addPart("payload", xml );
    NormalizedMessage res =
    deliveryService.request("CreditRatingService", "process", nm);
    Map payload = res.getPayload();
    out.println( "BPELProcess CreditRatingService executed!<br>" );
    out.println( "Credit Rating is " + payload.get("payload") );
    500 Internal Server Error
    java.lang.Exception: Erstellen von "ejb/collaxa/system/DeliveryBean"-Bean nicht erfolgreich. Es wurde folgende Exception gemeldet: "javax.naming.NameNotFoundException: ejb/collaxa/system/DeliveryBean not found
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.rmi.RMIServerContext.lookup(RMIServerContext.java:207)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.ApplicationContext.unprivileged_lookup(ApplicationContext.java:257)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.ApplicationContext.lookup(ApplicationContext.java:197)
         at javax.naming.InitialContext.lookup(InitialContext.java:351)
         at com.oracle.bpel.client.util.BeanRegistry.lookupDeliveryBean(BeanRegistry.java:279)
         at com.oracle.bpel.client.delivery.DeliveryService.getDeliveryBean(DeliveryService.java:250)
         at com.oracle.bpel.client.delivery.DeliveryService.request(DeliveryService.java:83)
         at com.oracle.bpel.client.delivery.DeliveryService.request(DeliveryService.java:53)
         at _InvokeBP._jspService(_InvokeBP.java:65)
         [InvokeBP.jsp]
         at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.3.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
    Message was edited by:
    user603180
    Message was edited by:
    user603180
    Message was edited by:
    user603180
    Message was edited by:
    user603180
    Message was edited by:
    user603180
    Message was edited by:
    user603180
    Message was edited by:
    user603180
    Message was edited by:
    user603180
    Message was edited by:
    user603180

    Here is the solution:
    Properties props = new Properties();
    props.setProperty("orabpel.platform", "oc4j_10g");
    props.setProperty("java.naming.factory.initial",
    "com.evermind.server.rmi.RMIInitialContextFactory");
    props.setProperty("java.naming.provider.url", "ormi://localhost/orabpel");
    props.setProperty("java.naming.security.principal", "oc4jadmin");
    props.setProperty("java.naming.security.credentials", "welcome1");
    and several jars have to be added to the project:
    Orabpel.jar , Orabpel-common.jar, oc4j*.jar,
    %ANT_HOME%\lib\ant.jar;
    %ANT_HOME%\lib\xercesImpl.jar;
    %ANT_HOME%\lib\xml-apis.jar;
    %AXIS_HOME%\lib\axis.jar;
    %AXIS_HOME%\lib\axis-ant.jar;
    %AXIS_HOME%\lib\commons-discovery.jar;
    %AXIS_HOME%\lib\commons-logging.jar;
    %AXIS_HOME%\lib\jaxrpc.jar;
    %AXIS_HOME%\lib\log4j-1.2.8.jar;
    %AXIS_HOME%\lib\saaj.jar;
    %AXIS_HOME%\lib\wsdl4j.jar;

Maybe you are looking for

  • Imac g5 ppc new hard drive update tiger10.4.11problem

    I replaced the hard drive in my Imac 20" g5 ppc 2.1gh installed tiger version 10.4.6 from my black retail tiger install disk. i want to update to tiger 10.4.11 but when i try i get a messsage update cannot be installed the digital signature for this

  • Using clips created in Flash Professional

    Hello! A newbie question: When working with AS in Flash Builder, Is it possible to use a MovieClip that I have created in Flash Professional? How? I wrote a simple game in Flash Professional, 99% of it is pure code (AS3) but one of the building block

  • Loading XML file into non-XML table(s)

    HI Gentlemen, I successfully registered my schema and generated an xml-based table and a TYPE. However, I do not have the table that would correspond to this TYPE. How do I get to it? How can I use FTP or HTTP protocol to load actual data from the co

  • APP payment

    Hi all, For a particular vendor(say 100000) in master record the payment method is defined as C(check). When i am  posting an invoice with that vendor i am changing the payment method to A(ACH).Now if i do payment thru APP for that vendor it is clear

  • Contact Request

    How do I know if somene has received a contact request? A friend, who is not computer literate at all,  denies receiving my contact requests. He says he has sent requests to me but I haven't received them. Is there a way to check this?