Monday, June 27, 2011

Determining Absolute Path in a Web Application

I was looking at the NetBeans EE forums, and someone asked how to determine the path in a web application. This is a common question so I thought I would provide two examples. The first is a servlet which returns the absolute path to the web application root. The other is a JSF application that does the same thing, and lists the files.
Note: The code is based on Java EE 6.

PathServlet.java



DirectoryLister.java



index.xhtml


Login Page Examples (j_security_check)

I have created a number of login page examples for use with Tomcat 6 which use j_security_check in the browser. There are three examples included:
  1. HTML based login page
  2. HTML and JSF Hybrid login page
  3. JSF based login page

Note: The JSF based login page is REQUIRED to still use an HTML <form> tag.

These examples were developed in NetBeans and are located here: LoginPageExamples.zip.
Enhanced by Zemanta

Sunday, June 26, 2011

How to Check JDK Supported Encodings and Locales

A map of the various different languages in EuropeImage via Wikipedia
I was working on an issue with a customer about supported locales.  The JDK comes in two varieties: one is for only western languages including European languages, and the other is multilingual. This includes languages like Thai which have different glyphs. The supported encodings for Java 6 are defined here: Supported Encodings. The issue was a download of the standard JDK download on Windows which does not include charsets.jar for use in an international application.

I figured out the issue by creating a simple web application to check the encodings. I figured I would provide it just in case other folks may be able to use it Otherwise it would just be good simple code gone to waste. Here is a link to the maven project: SupportedLocales.zip


Enhanced by Zemanta

Popular Posts