Redirecting browser from an applet with POST

Hi,
How can I cause an applet to redirect a browser window using a POST request?
Thanx,
Yaron

redirect using postIf you mean send a post request and let the http resonese redirect the page then
you have 2 options.
1.
set values of html object from the applet (calling javascript):
this.getAppletContext().showDocument(
                         new URL("javascript: someJSFunction('param','param');"));Submit the form from the applet calling javascript (see above).
Note that I don't use JSObject since that one makes mozilla crash since jre 1.5
2.
Use URL and URLConnection to POST your data.
Then use this.getAppletContext().showDocument() to navigate the the redirected URL (according to response from the URLConnection)
Using POST:
http://forum.java.sun.com/thread.jspa?threadID=645830&messageID=3816955
3rd post

Similar Messages

  • Opening a browser from an applet

    I got a problem, I want to open a browser from my applet, but I just found one way:
    getAppletContext().showDocument(new URL(
    "http://www.java.sun.com"), "_blank");
    but the problem is: with this, the default browser with defaul settings is opened, and that's what I don't want...
    how can I open the browser with some settings (for example size, or no-url-bar, etc)
    thx for help

    hi,
    try this code:
    public void showDocument(java.net.URL url, String targetWindow)
    when targetWindow can be:
    "_blank" Display the document in a new, nameless window.
    "windowName" Display the document in a window named windowName. This window is created if necessary.
    "_self" Display the document in the window and frame that contain the applet.
    "_parent" Display the document in the applet's window but in the parent frame of the applet's frame. If the applet frame has no parent frame, this acts the same as "_self".
    "_top" Display the document in the applet's window but in the top-level frame. If the applet's frame is the top-level frame, this acts the same as "_self".

  • Closing Web Browser from an Applet

    Does anyone knows how to close the Web Browser from an Applet ?
    Also Is there a way to close a browser which is intantiated from using ApplteContext ().showDocument ("....","_Blank").
    Thanks
    Sohan

    Hi kavinjir!
    Using class netscape.javascript.JSObject is possible to interact with javascript which can easily close the window browser but I'm afraid about the newest one because it isn't a child window. If this newest window contains an applet both (applets) can interact and send/receive "messages" to trigger an event (e.g; close via javascript again).
    Best Regards.

  • How to close the browser from an Applet?

    Hi,
    I've written one applet, with 2 buttons (Continue & Exit). On click of Continue button, it will open another web page. On click of Exit button, the browser should be closed.
    I'm not able to close the browser from the applet.
    Can any body help me.
    Rgds
    Santosh

    In my experience, calling Javascript from applets is flaky at best. However, I have gotten it to work in some cases. The following code should get you started:
    netscape.javascript.JSObject win = netscape.javascript.JSObject.getWindow(applet);
    Now you can call different methods on the win object (look into Javascript documentation for details).
    It also depends on if you are using the Java Plug-in or the JVM built into the web browser. You probably need set MAYSCRIPT=TRUE in your HTML. Look into the Java Plug-in documentation for details...

  • Can you disable the status bar on a web browser from an applet?

    I have a signed applet and am using plugin 1.3.1_02 with IE 5.5. I use the showStatus("text") method to display pertinent information to the user in the browser's status bar.
    Currently I see all types of messages being displayed (in IE's status bar) as my applet communicates with the server. I would like to restrict what is shown in the status bar to show my system messages only.
    Can I filter what is displayed or disable status bar functionality programmatically from the applet? Or possibly with a browser/plugin setting?
    Thanks

    Hi,
    I think you can do that with Java to JavaScript communication.
    thanks,
    Srinivas.

  • Open a Specific browser from an applet

    We can open a browser using appletContext().showDocument() Or even using Runtime.getRuntime().exec(rundll32,url.dll,FileProtocolHandler),
    but how can i specify a specific browser in applet. I have an application which works only in IE.

    You can't open a specific browser (if the applet is unsigned), and what's the problem with showDocument()?
    The need for this is unclear to me.

  • Can i open a page in Browser from an applet

    i want to open a web site in a new browser window from an applet.
    Is it possible. if posible then send me some links or codes
    thank you

    Do you know how to use applet to link to another webpage? set the target = _blank
    public class App extends Applet {
    getAppletContext().showDocument(new URL("http://java.sun.com"),"_blank");
    }

  • 'Browse' from an applet

    Hello again! I have an applet in a JSP which runs on tomcat server. Is there any way to have a button in the applet which opens a 'Browse' dialog, where to select a file (any type) and send it to the server? Or JavaScript is the only solution?
    Mihai

    To do that in the applet, you need to sign the applet. But you can do it with a plain old-fashioned html form.
    Javascript is in no way necessary.
    Whatever way you choose to send the file from the client, you do of course need something on the server to take care of it. If you use a HTML form, and since you have a tomcat server there, the best is to make a servlet using the com.oreilly.servlet package. (Google for it for details.)

  • Mail redirect rule only redirects mail from certain domain!!!

    Hi all,
    I set up a rule in Mail to redirect EVERY message to a certain email address (for backup/storage purposes) However it only redirects emails from email addresses with the same domain as my email (eg will redirect mydomainname.com but not otherdomainname.com
    Why is this??? Any ideas on how to fix it??? It is getting the mail from an Exchange server if that helps any...

    Thanks for the welcome!
    Ok so here are some screenshots...
    Here is the screenshot of the rule details
    Here is the main rules window
    And here is a screenshot showing how some are redirected and some are not (the ones that are redirected (and the one that shows the forward icon (it was forwarded before I set up the redirect rule)) are all from the same domain as my email account.
    Any ideas? Thanks!

  • How to refresh a client's browser from server without using Timer !

    Hi,
    can anyone have the code for refreshing the client's browser from server side with out setting the timer . U can do this by setting the Timer from server. but we need some other solution for this problem.
    Thanks.

    There's a meta tag for it.
    Kind regards,
      Levi

  • Using POST from an applet

    Hi,
    I need to connect to a URL from my applet and have the results show up in a new browser window. I have to use POST method since I need to submit a lot of parameters with the request. If I could have used GET method instead, this could have easily been accomplished using showDocument method. Even though applets can connect to a URL using POST, I could not locate any information on how to display the results in a new browser window. Anyone know how this can be accomplished?

    To POST data to servlet :
    - get data in applet by using getText() or getSelectedItem ...
    - Open connection by URL class
    - Open outputStream by BufferedWriter class
    - Using write(String) to write data then close the tream
    - to Receive data from servlet : getInputStream by BufferedReader class and then using readLine() to read data .
    - Notice : you must make a protocol for your Applet and Servlet able to interface with it other
    Good luck !

  • Closing browser window from an Applet?

    I've written a series of applets that perform different functions. I placed a button on each applet with the purpose to close the window in which that applet is running. However I don't even know where to start looking to find out how to make my applet close it's own browser window. I know how to open a new browser window from an applet but not vice versa.
    Can anyone help please?
    Mark.

    Right, I sort of tracked down some code that uses getMethods to allow me to invoke a Javascript command. It is not pretty and took a little bit of editing to get to work but it does the job without putting JS stuff into my HTML.
    However it is causing some problems. If I open one of my other applets it will only let me close that window and the previous applets ceases to respond at all. I think this may be because the invoke gets the JSObject which is the window and somehow having more than one applet open in different windows is causing it to get confused and is locking the first window and only responding to the second.
    I have seen a much simpler method that uses:
    import netscape.javascript.*;
    and JSObject to get the window but my compiler complains about the import. Any further suggestions or an example would be welcome as my current solution is a bit limited as you can effectively only have one window open at a time which doesn't suit my needs.
    Many thanks.
    Mark.

  • Problem in Closing Browser window from an Applet.

    I have wriiten a small Applet progarm that calls a Javascript function in the opening window, to close the window in which it is loaded.The Applet window is a PopUp window from one of my application's window.
    First time I start my application and load that Applet and then close the frame window,it works fine that the browser window will close, when the frame window is closed.It calls the window closing event in that applet stop method is called and In stop methd a closeLaunchedBrowser method will called this has a Javascript method and the Method closes the window using the self.close() method.
    But now if I continue this process of launching applet and then closing frame window, initial 1 or 2 steps it has know problem when I continue this, after 3 or 4 steps, it result in browser hang/crash.
    I am using java version 1.4.2_01 or higher and IE or Firefox(any other NetScape based) browser to load applet.It works fine with IE but getting problem in case of Firefox(any other NetScape based).
    The error dialog information and related event log generated is shown below :
    The dialog which is displayed before crashing of firefox has information :
    "firefox.exe has generated errors and it will closed by windows.you will need to restart the program.
    An error log is being created."
    The error log information :
    Source : Browser Event ID: 8032
    "The browser service has failed to retrieve the backup list too many times on transport \Device\NetBT_Tcpip_{611A64A2-8F4B-409E-9AB2-0D9BF741E791}. The backup browser is stopping.
    The code related to this is given below.
    import javax.swing.JApplet;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import netscape.javascript.JSObject;
    public class TestApplet extends JApplet {
    protected JSObject win = null;
    private JFrame frame = null;
    private boolean alreadyClosed = false;
    public void init(){
    this.win = JSObject.getWindow(this);
    frame = new JFrame("Test Frame");
    frame.setSize(300, 400);
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.out.println("windowClosing");
    TestApplet.this.stop();
    frame.show();
    public void stop() {
    if (!alreadyClosed) {
    alreadyClosed = true;
    closeLaunchedBrowser();
    System.gc();
    System.runFinalization();
    private void closeLaunchedBrowser() {
    final TestApplet thisObject = this;
    Runnable r = new Runnable() {
    public void run() {
    try {
    JSObject win = (JSObject)JSObject.getWindow(thisObject);
    if (win != null && win.toString() != null) {
    //win.eval("top.opener=self;self.close();");
    //win.call("close", null);
    win.eval("self.close();");
    } catch (Exception e) {
    Thread t = new Thread(r);
    t.start();
    }If any one know solution regarding how to aviod this crash of browser please let me know. I will be very thankful to you.
    Thanks.

    Right, I sort of tracked down some code that uses getMethods to allow me to invoke a Javascript command. It is not pretty and took a little bit of editing to get to work but it does the job without putting JS stuff into my HTML.
    However it is causing some problems. If I open one of my other applets it will only let me close that window and the previous applets ceases to respond at all. I think this may be because the invoke gets the JSObject which is the window and somehow having more than one applet open in different windows is causing it to get confused and is locking the first window and only responding to the second.
    I have seen a much simpler method that uses:
    import netscape.javascript.*;
    and JSObject to get the window but my compiler complains about the import. Any further suggestions or an example would be welcome as my current solution is a bit limited as you can effectively only have one window open at a time which doesn't suit my needs.
    Many thanks.
    Mark.

  • Redirect page with POST method in JSTL

    how to redirect page with POST method in JSTL.
    below is the code that i make, but the page redirected with GET method,
    so, the URL shown as http://localhost:8080/tes2/coba2.jsp?nama=saya
    how to hide the parameter, so it didn't show at the URL..??
    anybody help me..??
    server1 -> coba1.jsp
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <html>
    <head>
    <title>coba1</title>
    </head>
    <body>
    <c:url value="http://localhost:8080/tes2/coba2.jsp" var="displayURL">
      <c:param name="nama" value="saya"/>
    </c:url>
    <c:redirect url="${displayURL}"/>
    </body>
    </html>server2->coba2.jsp
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <html>
    <head>
    <title>coba2</title>
    </head>
    <body>
    <c:forEach items="${param}" var="currentParam">
            <li><c:out value="${currentParam.key}" />
                = <c:out value="${currentParam.value}" /></li>
          </c:forEach>
    </body>
    </html>

    There are other two way communications methods as well. One such would be:
    Server1Page1: Take response with parameters.  Use HttpURLConnection to make a request to DataInputServlet
                  on Server2 and send the parameters there with a POST operation
    Server2DataInputServer: Takes request with data in it and starts a new session.  Puts the data into the session and
                  returns the session id to the requester
    Server1Page1: Reads the response from the DataInputServer (the session id) and generates a sendRedirect to
                  Server2's display page using the session id.  Server1Page1 is now done.
    Server2Page1: Gets a request from the client with the session id, and pulls the parameters out of the session.  Then
                  can continue as normal.Server2Page1 can also do a quick refresh to itself not using the session id as well, which will keep the URL visible by the client relatively clean.

  • How to run an applet with JDBC connectivity on a web browser

    I've created an Applet in Java with SQL connectivity...i.e. it retrieves certain data from a table in SQL and puts in the TextField.....
    Now, the problem is that this Applet works in NETBEANS....but fails to work when I use a web-browser..or the "appletviewer" command....
    It says that it doesn't have permission to access local files....On Research, i've found that it is somethin' related to the concept of "Signed Applets", "Permissions" & "Security Policies" in java which doesn't allow any applet (without Certificate) to access Local Files.....
    Can Somebody please tell how to overcome this problem.....?

    I'm going to be blunt with you. You are most likely going to have to redesign your application from scratch. And if it turns out you don't have to then you should anyway because it's a bad idea and fraught with peril.
    Anyway here the major touchpoints on this discussion. You can be the judge of how these various points apply to you.
    - Applets are restricted. - Yes Applets have a number of security restrictions on what they can or cannot do. This is designed to protect users from malicious applets. By signing your applet you can request permission from the user to do certain activities that are otherwise restricted. But not all.
    - If you are using the JDBC-ODBC bridge then you need a different driver. If you sign your applet it might work in some limited scenarios but it will be hairy and is discouraged.
    - If you are using Access or another file based database (CSV Excel etc) then you are doomed. You'll have to get yourself a different database. A non file based one. It doesn't matter if you sign your applet or not. You're still doomed.
    - If you are trying to connect to a database server that is not at the same physical address as your web server you are doomed. Signing the applet will not help
    - Connecting directly to a database from an applet is extremely risky business. Starting with now anyone can steal your username and password for your database quite easily.
    What you should do in the redesign is put all the database accessing code in a Servlet. This Servlet does not have to be Java, it could be PHP, Perl, ASP, etc. It doesn't matter. Just put it on the server side. Then have your applet connect to this code via a webservice to do what is required.

Maybe you are looking for

  • Volumes OK, then press play and volumes wrong!!?

    I have carefully crafted the volume and pan levels for each instrument. I then press play, either from the very beginning or from any point in the middle, and the volume levels or effects or both are not correct. To Fix the problem, I pick ANY tracks

  • Permissions Error in Complier

    I have transferred my website from another pc, i have not changed a thing and. started up TomCat. A number of the pages work correctly, but i get the following error on other pages. org.apache.jasper.JasperException: Unable to compile class for JSP C

  • Error while starting up dreamweaver

    Hi, i got this error while starting up dreamweaver, reinstall has been done. Does anyone know? Thanks

  • Multiple channel DAQ-1200

    I am trying to acquire data from to channels in differential mode. Though the test panel shows the data as expected when I use a modified version of SCANsingleBufSync, I seem to be acquiring the same data on both channels, none corresponding. Any adv

  • Zen XFi- 2 crashed and can't see any files on the player after reset

    My zen crashed yesterday and after i reset it - everything that was on the player has gone - music pictures applications etc - however if i plug the player into the PC all music etc is still on the player - i have reloaded the firmware but no joy - a