Unable to use javascript to close existing window in jsp

Hi experts,
In my jsp, i've a code that prompt user to download the file (using response.setContentType) to their machine within a try and catch statement.
I would like my existing window browser to close immediately after the prompt to the user.
I tried using javascript window.close() but there isn't any effect. I even place my javascript code at the end of the jsp code but also no effect.
In fact, i tried to print something out using out.println() there isn't any effect at all either. So I tried using system.out.println(), it works. (printed out in my tomcat)
Anyone know what should I do in order to close the window?
Thanks!

hmm.. actually i don't really get what you mean.
For my case, I didn't use window.open.
what happened is, i have a html page that prompt user to enter a name for their file. after the user has entered the name, it will submit as a form to a jsp page to do some file conversion. then pass to another jsp page to prompt user to save the file to disk.
the window was pop up for the downloading of file to disk, but behind it, the html window that was pop up earlier (window that prompt user to enter the name) was still there.
eg: a.html -> b.jsp -> c.jsp -> new window for saving of file
window for a.html still around.
In this case, can i still use your method?
Thanks alot!

Similar Messages

  • HTML-DB OAE Javascript to close current window and open a new window

    Hi everybody,
    We work with 1.6.
    What we want is to close the current window and open a new window with the URL mentionned in the window.open('http://www.cf.qc/pls/portal/PORTAL.....,'newwindow').
    The new window opening fires only once although we call it many times.
    Our javascript is:
    function closeTest()
    { alert('closeTest');
    if('&REQUEST.'=='QUITTER2'){     
    w = window.self;
    w.opener = w;
    w.close();
    window.open('http://www.cf.qc/pls/portal/PORTAL.home','newwindow','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
    We call it on our application attributes :
    OnLoad="closeTest()"
    Thanks. Bye.

    Try this on for size:
    I have included two functions.
    windowRebuild() - opens a new window, maximizes it based on the screen size, removes all toolbars, and then closes the old window.
    myLocation(appName, pageName) - builds a url referencing an HTMLDB application, specfic to what server you are currently on. Very useful when you have an application on 3 different servers(dev, test, prod servers), you wouldn't want the server name hardcoded if you plan to export the app to another server.
    Also, you need to be careful when using &APP_ID. I am not completely certain how that is resolved at runtime, but I've found it only works when the javascript is in the HTML Header of a page and not stored in the template of the page.
    <script language="JavaScript1.1" type="text/javascript">
      This functions is for internal application use.
      Examples of myLocation:
      url = myLocation('&APP_ID.', 'APP_PUBLIC_PAGE');
      url = myLocation('MY_APP_ALIAS', 'MY_PAGE_ALIAS');
      url = myLocation('184', '10');
    function myLocation(myApp, myPage){
      var myHost = location.host;
      var newURL;
      newURL = 'http://'+myHost+'/pls/htmldb/f?p='+myApp.toString()+':'+myPage.toString();
      return newURL;
    /*  Function windowRebuild()
    *   This function will open a new window and close the old window.
    *   This function will also maximize the new window and remove all toolbars.
    function windowRebuild(){
       if(window.name != 'myAppWin'){
        var url = myLocation('&APP_ID.', 'PAGE_ALIAS');
        var myWin = window.open(url,'myAppWin','toolbar=0,scrollbars=1,menubar=0,status=1,resizable=1,location=0');
        window.opener = 'x';
        window.close();
       if(window.name == 'myAppWin'){
        window.moveTo(0,0);
        window.resizeTo(screen.availWidth,screen.availHeight);
    </script>Let me know if that works or you need some more explanation.
    Chris

  • Firefox closes existing window when you open and close a new window

    When I'm using firefox and need to open a new window (or a website opens a new window) and I'm done with that new window and close it, Firefox attempts to also close the previous window that I am using. I've tried reinstalling, but other than that I don't know what to do. What usually happens when I close the window is that I have multiple tabs open in the other one and it asks me if I would like to close all my tabs. When I hit cancel, it asks me again. Once I hit cancel the second time it stops bothering me.

    I thought it was doing that also. But I found that if I start a new chat with someone I was messaging before, then the old messages re-appear in the messages window.

  • Using javascript to resize the window

    I've got a project that I would like to resize depending on which slide the learner is viewing.
    I' aware that the javascript method:
    window.resizeTo(width,height)
    can be used to resize a window.
    In my case I want it to be for the tall window:
    window.resizeTo(1016,650)
    and for the short window;
    window.resizeTo(1016,165)
    I'm also aware that you can tell a button (or anything else) to execute javascript.
    I'm having trouble making it work, tough.
    I've tried putting the method directly into the Script_Window for the button.
    I've tried writing a function in the published file, then having the button call that function.
    Can you paste javascript snippets into the Script_Window? Or do you need go the whole 9 yards and write the entire function, name the button instance, and tell the Captivate button to call that function?
    I'm just now sure how much Captivate knows how to do and how much I need to tell it.
    Thanks in advance!
    Joe           

    Thanks for your response, Jim.
    My window was created by a previous window using the code:
    <script language="JavaScript">
    function newWindow() {
    TheNewWin = window.open("main.htm","newWin","status=no,resizable=yes,left=0,top=0,width=1014,height=6 50");
    TheNewWin.focus()
    </script>
    I tried the code above in the ScriptWindow of a Captivate button (running in a Captivate SWF in the new window). It didn't work.
    I also tried:
    TheNewWin.resizeTo(1016,165);
    and
    newWin.resizeTo(1016,165);
    neither of which worked.
    Any other guidance would be appreciated.

  • [SOLVED] Unable to use Javascript editor in any browser

    I'm not able to edit a Tumblr theme because I cannot find a browser compatible with their Javascript editor, which unfortunately is a requirement.  I was hoping to use Firefox, which I know works on Windows, but all the editing controls such as copy/cut/paste are lost.  I have read many articles on the subject, including addons such as "AllowClipboardHelper" but I believe they're all outdated or irrelevant, since none of the solutions work.  I tried using Epiphany, Chromium, Opera, and Midori, but they all seem to do worst.  Some don't even display the text.  I did find one way though, namely to use Rekonq (not Konqueror) in KDE, but I'd much rather use Firefox in Gnome if possible.
    Edit:
    It turns out that it was the "All-In-One-Gestures" addon that caused the problem.  Once disabled, the editor works as expected.  However, I still don't see why it fails in the other browsers.  Feel free to delete this post.
    Last edited by coproduct (2012-08-15 23:07:15)

    well.. this question has little to do with the VMware kit.. it's a generic SQL*Plus question.. following 3 keywords: "sqlplus default editor" in google give the answer..
    1. from the shell use EDITOR as environment variable.
    $ export EDITOR=emacs
    2. inside SQLPlus you can use "define _EDITOR=emcas"
    3. to get out of that afiedt.buf prompt, just hit Control-D.
    4. As I recall emacs is not installed due to space considerations.
    enjoy,
    Saar.

  • Opening an external link using javascript.  Keeping new window in front

    I am displaying a photo from an external link when called upon from my swf.  When the user clicks a button, up pops a corresponding photo in a new browser window.  After the photo window has opened, if the user clicks another button the photo browser will update but its no longer in front.  I know I need to use the focus() command but cannot figure how to incorporate it into my AS3 code.
    var req=new URLRequest();
    function scrollPanePopulate(event:Event){     
         //create the temp variables
         var calledPhoto=pntxml.row[pointindex].PhotoUrl;
         req=pntxml.row[pointindex].PhotoUrl;
         var jscommand:String = "var newwin=window.open('"+req+"','win','height=400,width=600,left=650,top=50,toolbar=no,scrollbars=yes,location=no');";
         var url:URLRequest = new URLRequest("javascript:" + jscommand +"void(0);"); navigateToURL(url, "_self");
    The above code works great but I want to keep the photo window in front when it is refreshed.  Any suggestions?
    thanks in advance...
    -josh

    var req=new URLRequest();
    function scrollPanePopulate(event:Event){    
         //create the temp variables
         var calledPhoto=pntxml.row[pointindex].PhotoUrl;
         req=pntxml.row[pointindex].PhotoUrl;
         var jscommand:String = "var newwin=window.open('"+req+"','win','height=400,width=600,left=650,top=50,toolbar=no,scrollbars=yes,location=no');";
         var url:URLRequest = new URLRequest("javascript:" + jscommand +"void(0);newwin.focus();");
    navigateToURL(url, "_self"); }
    //  p.s.  you should be using externalinterface class.

  • Can't use "ENTER" to close some windows?!?!?

    I just installed AE CS5 on a new Mac 12-Core, running OS 10.6.4.
    AfterEffects seems to be working, overall, but I have found some buggy and extremely irritating behavior. Specifically, I'm finding that when I open the "composition settings" or the "solid settings" I am not always able to use the "RETURN" or "ENTER" keys to close the specific window. I am forced to click on the "OK" button with the mouse. Is this a known bug? Or am I missing something, like a settings somewhere?
    Please help, as this is a TOTAL efficiency killer with big projects.
    Thanks!

    I'm trouble-shooting this right now, and I think I may be on to something...
    Part of the problem seems to be when I try and alter the comp background color, or the color of a solid layer. So, I turned "OFF" the "use system color picker" in the prefs. I have NOT been able to make the original problem repeat since doing this!!!
    That being said, still a big nuisance considering that I much prefer the system color picker to that of Adobe.
    Can anyone else please test this?

  • Unable to use C++ dll in the windows phone 8 application.

    Hi folks,
    I am trying to use the native c++ dll compiled for Win32 platform using PInvoke. The native dll is a simple library which is returns some dummy values of native data types. The dll is working fine with the traditional Windows Forms Applications. But when
    I am trying to use the same dll in the Windows Phone 8 app, I am getting a runtime exception, "An exception of type 'System.NotSupportedException' occurred in Unknown Module. but was not handled in user code".
    [System.Runtime.InteropServices.DllImport("win32dll.dll", EntryPoint = "Hello")]
    private static extern int Hello();
    As one can see the InteropServices classes in Windows Phone 8 sdk, the PInvoke must be supported! am I going wrong some where? Can some one give me sample windows Phone 8 app project which is using native C++ dll.

    Here's the official list of InteropServices classes supported by the phone:
    http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.runtime.interopservices(v=vs.105).aspx
    DllImport isn't one of them.
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
    objects and unknown namespaces.

  • Unable to use jstat with Weblogic on Windows

    JDK 1.6.0_26 HotSpot
    Windows Server 2003 SP2 Enterpise x64
    Hello,
    I am trying to use jstat and other similar tools to examine gc info. If I run jps, I only see the PIDs for jps, and jstatd (if I have it running). I am running Weblogic using Node Manager. Is there something I need to add to Node Manager property file to make the java.exe processes visible to jstat?
    Thanks,
    Rob
    Edited by: user10750497 on Oct 12, 2011 3:39 PM
    Added Os and JDK info

    Console Output
    works for characters covered by Lucida Console font if the first character in a line is ASCII (code < 128, e.g. blank)
    CHCP 65001
    sqlplus
    SQL> select ' ', unistr('Josef \0419\043E\0437\0435\0444') from dual;
    Josef Йозеф
    SQL> select ' ',unistr('Euro \20AC') from dual;
    Euro €
    Sven, windows is able to render the output (as covered by Lucida Console), but there is a quirk in MSVCRTxx (C Runtime-Lib), function fwrite(). The first byte in a line is passed separately to an isolated single write() call, which causes conversion of an utf8 sequence to fail.
    Console Input
    For non-ascii characters (code >= 128), ReadConsoleW must be called, e.g. through a simple filter converting UTF-16 stdin to UTF-8 stdout.

  • Unable to use WFDDisplaySinkStart API in a Windows 8.1 Desktop application project.

    Does anyone know where the following files are located within the SDK?
    Header: Wfdsink.h
    Library: Wifidisplay.lib
    Thanks!

    "User-Agent Strings"
    That doesn't mean a lot, I'm sure, but it's the root of your problems, and Flash Player has nothing to do with it.
    Microsoft "rewrote" the User-Agent Strings for the abomination they call their latest and greatest browser. User-Agent Strings are what websites use to identify the browser you're using and provide the proper content for it's browser engine, like ActiveX stuff, and Flash or HTML5 video. Thanks to the geniuses in Redmond, WA, the User-Agent Strings for IE11 (which has a Trident engine), ID it as either "Gecko" (Firefox) or "Webkit" (Chrome). Problem is: when the site the directs to the content for one of these two engines, the Trident engine in IE can't intepret it and the site then sees IE as an "unidentified" browser.
    The problem with an unidentified browser is that the plug-ins in that browser aren't recognized either, so even though you're up to date, it says you need the latest Flash Player when you use IE11. YouTube... has converted to HTML5 video so if it doesn't detect Flash Player, it can display HTML5 (MP4) video which requires no plug-in to play. Facebook can't do that, because HTML5 doesn't apply to games... only video.
    Microsoft has no plans to "fix" the mess they've created because they think it's a great idea to block you out of the websites you visit.
    They recommend using "Compatibility View" and pretending that you're using an older verison of IE... Problem with that is that it's seen limited success, and you have to enable it for EVERY page that has problems... individually.
    I'm not big on "pretending" so I recommend actually using another browser.
    Firefox (from Mozilla)
    Opera (from Opera)
    Safari (from Apple)
    Chrome (from Google)
    ANY of those will work where IE11 won't, with the Flash Player Plug-in (For all other browsers), and Chrome doesn't even need that because it has its own Flash Player plugin built in.

  • How do i not use "quit and close all windows", I Just Want Them To quit

    I want to close an application without having to  option click and quit command? PArK

    Command-Q will quit any application.

  • Unable to use pinch to close program

    II have an ipad 2 which has stopped accepting pinch to close or the ability to switch between screens with multi point gestures. I'm currently running iOS 7.

    Did you pinch with 5 fingers?

  • Unable to use product key of windows 8 for upgrading windows 10

    Hello, My laptop is Pavillion brought in India, model HP2000-2202TV with windows 8 installed,I am upgrading my windows to windows 10 i am unable to use the product key of windows 8 to upgrade windows 10.can you please suggest me what to do Thank youBhavana Gopal

    cuteanava wrote:
    forgot to mention, i did a fromat of drives due to some virus issues before installing it.Hi, That is a clean install that why it asks for the key. You can't clean install without a Windows 10 key. Please check the following answer:     http://windows.microsoft.com/en-us/windows-10/why-activate-windows-10 Regards.

  • Close parent window of Mozilla browser from Java

    Hi All,
    I want to open a URL in a controlled browser from java stand alone application. I was able to do this in Netscape of UNIX OS. The method followed is given below.
    1. Launch a temporary HTML file which contains Javascript (to launch the URL in a controlled window). This is done using --- Runtime.getRuntime().exec() method.
    2. Close the parent HTML file on 'onLoad' using Javascript. (self.close).
    [ I tried window.close() & top.close() also.]
    Now I need to support the same for "Mozilla" also. But mozilla just ignores the close() command of Javascript.
    1. Is there any alternative way to close the parent window in Mozilla browser ?
    2. Is there any way to close the parent window from java by using 'Process' class/ threads/ ??
    3. Any other way???
    Note : I am using the intermediate window for using Javascript. (controlling the browser properties). Since Java cannot communicate to Javascript directly, I am forced to have such an intermediate HTML file.
    Thanks in advance.
    surekha_Venugopal.

    Some more details :
    Mozilla browser will close a window using window.close() command, but only if the window is opened by the script. If not it will not close it.
    Here, I am opening the window from Java application. That is why closure of the window is failing.
    Trying to find a solution.
    Regards,
    Surekha_Venogopal

  • How can I close current window.

    I have a submitButton.
    When I click it, using a method of javascript to close current window.
    the coding like below:
    pageContext.putJavaScriptFunction(
    "closeCurrentWindow",
    "javascript:window.opener=null;window.close()");
    pageContext.getJavaScriptFunction("closeCurrentWindow");
    But I think it's not a idea.
    Do you have another recommendations about the solution of this problem?
    thx.

    Hi,
    I don't understand. Would you like to have a button to close the current window?
    Or should it do also something else?
    If you want only to close the window you can use a "button" (not item_style = "button", not "submitButton").
    Then you must set its Destination URI property to javascript:self.close();
    This will close the current window.
    However note that using javascript is not right, according to OAF standards.
    Bye
    Raffy

Maybe you are looking for

  • How can I print all my contacts including phone numbers from iCloud

    I used to be able to print all of my contacts including phone numbers etc from iCloud.  Since all the upgrades I can not do this.  I used to be able to change the display by clicking on a ribbon at the top then clicking the gear to have it print.  No

  • Nested for loop in the collections

    Hi Experts, collection1 ============ SELECT o.object_id       BULK COLLECT INTO l_obj_info         FROM (SELECT     n.node_id, n.object_id                     FROM nodes n               START WITH n.node_id = 100               CONNECT BY PRIOR n.node

  • AV digital adapter (MD098ZM/A)

    Try to get a brand new (from Best Buy) AV digital adapter to play Netflix using an iPhone 4 and then later using an iPhone 4S.  It worked brilliantly (very sharp) with both phones - but only the first time.   With all subsequent attempts I would get

  • How can i play a tv show's full season continuously on iOS7?

    On iOS6, there was a big play button on the rh corner, but I don't see it on ios7. Any help is greatly appreciated.

  • Get pernr late

    hello friends. please anybody tell me in what conditions can we use get pernr late event. can we give get pernr late after end-of-selection. pls explain with an example. thanks