This discussion is archived
1 Reply Latest reply: Jul 25, 2012 6:10 PM by EJP RSS

getAppletContext().showDocument() doesn't work with javascript turned off

949428 Newbie
Currently Being Moderated
Is it true to say that

getAppletContext().showDocument(new URL(getDocumentBase(),newUrl)); doesn't work when Javascript is turned off ?

I have a JSP page where the following applet is embedded

----------------------------------------------------------------------------

import java.net.URL;
import java.applet.*;
import java.net.URLEncoder;
import java.net.MalformedURLException;

public class jreCheck extends Applet {

public void init() {
          
               try {
          
               String data = "javaVersion=" + URLEncoder.encode(System.getProperty("java.version"),"UTF-8");
               String newurl = "http://localhost:8080/test/jstest.jsp?"+ data;
               System.out.println("new url is : " + newurl);
               getAppletContext().showDocument(new URL(getDocumentBase(),newurl));
               
               } catch(Exception ex) {
                    
                    
                         System.out.println(ex.getMessage());
                    }

}
}

-----------------------------

Here is the JSP:

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="java.io.*, java.util.*, java.net.*, javax.servlet.*, java.util.regex.*, java.io.BufferedReader, java.net.URL, java.net.HttpURLConnection" %>

<%

String jumpToPath = "http://localhost:8080/test/jstest.jsp?";
String detect = request.getParameter("detect") == null ? "" : request.getParameter("detect");
String javaVers = request.getParameter("javaVersion") == null ? "" : request.getParameter("javaVersion");
%>

<p>The java Version: <%=javaVers %> </p>

<%     if("".equals(detect ) && "".equals(javaVers) ) { %>

Verify Java version

<% } %>

<%     if("jre".equals(detect)) { %>
<!-- Detecting the JRE Version -->

<p>Running the applet </p>

<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="250" height="75">
<param name="type" value="application/x-java-applet" />
<param name="code" value="jreCheck.class" />     
<param name="jumpto" value="<%=jumpToPath%>" />
<comment>
<embed type="application/x-java-applet" code="jreCheck.class" width="1" height="2" jumpto="<%=jumpToPath%>" />
<noembed>No Java detected</noembed>
</comment>
</object>


<% } %>

--------------------------------------


When javascript is on, I see The jre Version: 1.6.0_31

When javascript is turned off, I see The jre Version:

But I still see my url in the Java console as new url is : http://localhost:8080/test/jstest.jsp?javaVersion=1.6.0_31

This says that my browser isn't being refreshed with the following statement in the applet - getAppletContext().showDocument(new URL(getDocumentBase(),newUrl));

Any thoughts please ?

Thanks!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points