Showing posts with label Firefox. Show all posts
Showing posts with label Firefox. Show all posts

Friday, November 05, 2010

Installing GWT Developer Plugin in Firefox 3.6 for Linux

If you are developing GWT web apps on a Linux system with Firefox 3.6+, then you might have been prompted to install the GWT Developer Plugin when trying to debug your app on Firefox (see image below).


The problem happens when you try to install the plugin and restart Firefox - only to be prompted to re-install the GWT Developer Plugin again.

It seems like the latest Plugin on Firefox 3.6 requires the libnspr4.so.0d library and Mozilla Firefox 3.6+ only provides libnspr4.so. To solve this problem, simply locate the library and create a sym-link. For example, as root, execute the command:

sudo ln -s /usr/lib64/libnspr4.so /usr/lib64/libnspr4.so.0d

Then restart Firefox, install the GWT Developer Plugin, and then restart Firefox once more. You should now be able to debug your GWT web app!

Note that the location of the libnspr4.so library differs in each Linux distro. But here are a few common folders where it might be

/lib/
/lib64/
/usr/lib/
/usr/lib64/

If you are unable to locate the library in one of the directories above, you can try finding it by executing on the command:

locate libnspr4.so

UPDATE: The library should be provided in mozilla-nspr-32bit or mozilla-nspr.

Hope that helps some of you out! Leave me a comme
nt if you have any questions.


Friday, October 24, 2008

Sharing Java Applet Sessions in Firefox

There is a known problem in JEP (Java Embedding Plugin) for Firefox in which new sessions (or no sessions at all) are used for every new Java applet request to a servlet. This can be problematic for applets that requests data or URL from a servlet requiring authentication or a login. To get around this problem, you can pass in the current HTLM document's cookie as a Java applet parameter, and then use the cookie in the HttpServletRequest's Cookie request parameter.

In your HTML applet code, just add the document's cookie as a parameter. (Note that I'm writing the HTML applet code in JavaScript to dynamically get the document's cookie.)

<script language="JavaScript" type="text/javascript">
<!--
   document.write("<embed");
   document.write("name='MyApplet'");
   document.write("type='application/x-java-applet;version=1.6'");
   document.write("code='org/puguasoft/examples/MyApplet.class'");
   document.write("codebase='/applets/'");
   document.write("browserCookie='" + document.cookie + "'");
   document.write("</embed>");
-->
</script>
Then in your servlet, use the browserCookie parameter value as the Cookie property in the HttpServletRequest.
import javax.swing.JApplet;
import java.net.URL;
import java.net.URLConnection;

public class MyApplet extends JApplet{

   public void doIt(URL url){
      URLConnection urlConnection = url.openConnection();
      String cookie = getParameter("browserCookie");
      urlConn.setRequestProperty("Cookie", cookie);
      urlConnection.connect();

      // Now you can do what you need with the URLConnection
      // (e.g. open up an InputStream to read the data)
      // using the same cookie session.


   }
}

For more information check out these postings: