Monday, November 1, 2010

JBoss 5 getResourceAsStream

Recently I was testing JSPX on JBoss 5.1.0. The first thing we encountered is the failure of getting Resource Bundles or Message Bundles.

To get to that deeply, we need to know that JSPX is accessing resource files within the WAR/EAR file. The best example on that, the jspx HTML pages themselves.

The other need to access resources when loading resource Bundle. Embedded resources inside JSPX like javascript files and images are also accessed as resources.


When we moved to JBoss 5.1.0, we discovered that JSPX pages are opened normally however the resource bundles are not.


After check the source we found out that they are using different techniques:

  1. 1. Loading the JSPX Pages located in the WebContent. They are loaded using the Servlet Context context.getResourceAsStream(resourceName);
  2. The embedded resources and bundles are loaded by
    asResourceUtility.class.getResourceAsStream(resourceName);



And this used to work on JBoss 4.2.2 but now it is no on JBoss 5.1.0. we simply tried to use the servlet context to load everything, but it did not work for jspx embedded reources as they are inside the jspx jar.


It seems that JBoss separates the classpath of the loaded jars and web app. so using context to load embedded resources did not work. so it had to stay as it is. and the resource bundles to be loaded by servlet context.





Tuesday, June 29, 2010

jspx jar dependency

Jspx is requiring the following jars in case there is a business need.

  1. commons-fileupload-1.2.1.jar (when using File Upload)
  2. log4j-1.2.15.jar (Mandatory for logging)
  3. poi-3.1-FINAL-20080629.jar (when using Export To Excel)
  4. servlet-api.jar
  5. commons-io-1.3.1.jar (when using File Upload)




Monday, June 28, 2010

Jspx Documentation

Many questions about jspx documentation. Well, we do have a documentation.

check out the following link

http://jspx-bay.sourceforge.net/index.html?l=pages/tout/doc.html







Thursday, June 17, 2010

jspx at MEAOSS

jspx went public again at MEA OSS Forum http://www.meaossforum.com/overview, the first Middle East and African Open Source Software Forum.

jspx was well received by the audience. In the conference I met Sally Khudiri from Apache. She is a so sweet person.







Thursday, May 27, 2010

Jspx on Softpedia

Jspx has just hit http://www.softpedia.com . The framework was added to MAC and Linux section. Windows section is to follow.

here is the image from MAC section


http://mac.softpedia.com/get/Development/Java/jspx.shtml



and this is from Linux.
http://linux.softpedia.com/get/Internet/HTTP-WWW-/JSPX-57080.shtml




Sunday, May 23, 2010

Internet Explorer cannot download

In web development, sometimes it is required to download documents to the client. These documents may not be physically existing on the file system, however they are in other place like DB, that is requiring problematically extract the document then send it to the client.

Jspx provides a common method to write files directly to the client.



public

void
writeFile(byte[] file, String fileName, String mimeType)

This method can be called from any jspx controller.


In some application that is using SSL for HTTPS interface. we noticed that if the client side is IE then we got the following error.




Internet Explorer cannot download Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.


We googled the web for such error and ended with the result that is described here

http://support.microsoft.com/default.aspx?scid=KB;EN-US;q316431&

we had to remove both header (Pragma, Cache-Control)


so we did that in the writeFile method and now it look like this:


public void writeFile(byte[] file, String fileName, String mimeType)
      {
            try
            {
                  this.response.setHeader("Content-disposition", "attachment; filename=" + fileName);
                  this.response.setContentType(mimeType);
                  // [May 23, 2010 4:51:08 PM] [Amr.ElAdawy] [removing the caching control headers
                  // in order to solve the https problem]
                  this.response.setHeader("Pragma", null);
                  this.response.setHeader("Cache-Control", null);
                  OutputStream out = this.response.getOutputStream();
                  out.write(file);
                  out.close();
            }
            catch (IOException e)
            {
                  e.printStackTrace();
            }
            catch (Exception e)
            {
                  logger.error("Excpetion while writing file file ", e);
            }
            this.skip();
      }


which had solved the problem

cheers,







Tuesday, March 2, 2010

Video: jspx jdc 2010 Demo