Post Pic

NetBeans Visual JSF editor tutorial on web applications running over HTTPS displaying warning in IE “This page contains both secure and nonsecure items”.

Developers who have used NetBeans 6.1 and 6.5 for web development with Visual JSF (Woodstock) might have encountered an issue with their web application when deployed on a secured server (HTTPS) and opened with Internet Explorer. The issue lies in the way IE treats links to JavaScript and CSS files loaded in the pages. Under HTTPS, the links to JavaScript have to be absolute, not relative. IE does not assume that the “relative” folder is secured.

If you “view source” on the page that Woodstock generates, you will see the following line:

</span><code><script type="text/javascript" src="/app/theme/com/sun/webui/jsf/suntheme4_2-080320/javascript/bootstrap.js"></code><span style="font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 13px; line-height: 19px;">

Now if you change that line to:

</span><code><script type="text/javascript" src="https://www.yourserver.com:8443/ app/theme/com/sun/webui/jsf/suntheme4_2-080320/javascript/bootstrap.js"></code><span style="font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 13px; line-height: 19px;">

The site will now work under HTTPS without any security warnings. Obviously, this cannot be done straightforward because this piece of HTML code is generated by the Woodstock library. The solution we have implemented to resolve this problem is to change the code in the Woodstock library that generates the HTML header of the pages. The following solution is not the most elegant solution; it’s more of a simple workaround to solve this problem in production environment:

  1. Open the Woodstock project web site, https://woodstock.dev.java.net/index.html, and go to “Build it Yourself.”
  2. Follow the instructions on the “Build it Yourself” page to register and get a CVS access to download the framework source code. The CVS URL will be something like: :pserver:username@cvs.dev.java.net:/cvs. You don’t need NetBeans 5.5, as it is written in the compile instructions.
  3. Open the CVS repository with NetBeans and check out the module “woodstock/webui” and branch “Release42″ as a new project.
  4. Open the project and edit the “JavaScriptUtilities.java” file in package com.sun.webui.jsf.util in “src/runtime” folder.
  5. In method “renderJavaScriptInclude”   change line 578 from:
    </span><code>String jsFile = getTheme().getPathToJSFile(file);</code><span style="font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 13px; line-height: 19px;">


    To:

    </span><code>String jsFile = "https://www.yourserver.com:8443" + getTheme().getPathToJSFile(file);</code><span style="font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 13px; line-height: 19px;">

  6. Save the file and rebuild the project. During compile, you might notice a lot of warnings, etc – just ignore them.
  7. Copy and overwrite the newly compiled webui-jsf.jar and webui-jsf-dt.jar from the Woodstock source code folder “woodstockwebuidist” to the NetBeans subfolder. “visualweb2modulesext”. Keep a copy of the original jar files (see below).
  8. Rebuild your WAR file and deploy it on the HTTPS server.

There you go. You should now have your website working under IE with no security warnings. Note that the newly compiled .jar files will work only on the server URL you define in Step 5. They won’t work in localhost development environment, so you might want to change with original .jar files during development phase. Cheers.

6 Responses

[...] are some solutions to change de webui-jsf.jar library to hardcode the URL, since this is not the best [...]

02.05.09

Hi,

Using your example as a base, I have made it somewhat more portable by not needing to hardcode the server/port etc. The following lines will do this. :-

String uri=((HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest()).getRequestURI();
String url=((HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest()).getRequestURL().toString();
String bitineed = url.replace(uri, “”);
String jsFile = bitineed + getTheme().getPathToJSFile(file);

02.05.09

I am using the code provided by Scott. I saved the project adn did a clean and build. I am getting a BUILD FAILED message. Is this part of the messages to ignore?

02.05.09

@Ana Garcia

Ana,
I have not tried the code that Scott proposed. Have you tried the solution as I published it originally?

02.05.09

I tried it and it still fails on the build. I even deleted it and started all over without no luck. it says that is unable to access ..\lib\webui-tools.jar ; maybe I am not doing the steps correctly: when it comes back from tcheckout, it ask if I want it to open the project and I clickon Open Project, then I go and make the changes. save the file; run build. Did I miss something?

this is the last part of the output:
l10n-uptodate:
native2ascii:
Running native2asci for component\Bundle_de.properties,component\Bundle_es.properties,component\Bundle_fr.properties,component\Bundle_it.properties,component\Bundle_ja.properties,component\Bundle_ko.properties,component\Bundle_pt_BR.properties,component\Bundle_sv.properties,component\Bundle_zh_CN.properties,component\Bundle_zh_HK.properties,component\Bundle_zh_TW.properties,model\Bundle_de.properties,model\Bundle_es.properties,model\Bundle_fr.properties,model\Bundle_it.properties,model\Bundle_ja.properties,model\Bundle_ko.properties,model\Bundle_pt_BR.properties,model\Bundle_sv.properties,model\Bundle_zh_CN.properties,model\Bundle_zh_HK.properties,model\Bundle_zh_TW.properties,renderkit\html\Bundle_de.properties,renderkit\html\Bundle_es.properties,renderkit\html\Bundle_fr.properties,renderkit\html\Bundle_it.properties,renderkit\html\Bundle_ja.properties,renderkit\html\Bundle_ko.properties,renderkit\html\Bundle_pt_BR.properties,renderkit\html\Bundle_sv.properties,renderkit\html\Bundle_zh_CN.properties,renderkit\html\Bundle_zh_HK.properties,renderkit\html\Bundle_zh_TW.properties,resources\LogMessages_de.properties,resources\LogMessages_es.properties,resources\LogMessages_fr.properties,resources\LogMessages_it.properties,resources\LogMessages_ja.properties,resources\LogMessages_ko.properties,resources\LogMessages_pt_BR.properties,resources\LogMessages_sv.properties,resources\LogMessages_zh_CN.properties,resources\LogMessages_zh_HK.properties,resources\LogMessages_zh_TW.properties, it takes several minutes…
Unable to access jarfile C:\Source\woodstock42\woodstock\tools\woodstock\lib\webui-tools.jar
C:\Source\woodstock42\woodstock\webui\build.xml:455: The following error occurred while executing this line:
C:\Source\woodstock42\woodstock\webui\build-l10n.xml:63: The following error occurred while executing this line:
C:\Source\woodstock42\woodstock\webui\build-l10n.xml:264: Java returned: 1
BUILD FAILED (total time: 41 seconds)

[...] are some solutions to change de webui-jsf.jar library to hardcode the URL, since this is not the best [...]

Leave Your Response

* Name, Email, Comment are Required
MN Custom Software Development | MentorMate
Free SEO Analysis & SEO Tools | SpyderMate
SEO Presentation Download

MentorMate's Tweets

Posting tweet...