Recent Notes

Displaying keyword search results 1 - 6
Created by Fang on November 10, 2011 09:26:12    Last update: November 10, 2011 09:26:12
Syntax highlighted XML schema for JSF 2.0 Application Configuration Resource File ( faces-config.xml ). Almost 3000 lines! <?xml version="1.0" encoding="UTF-8"?> <xsd:sch...
Created by Fang on October 28, 2011 13:49:40    Last update: October 30, 2011 19:23:25
This is a simple example to demonstrate the templating power of JSF facelets. If you've used struts tiles before, you'll recognize the simplicity of templating with facelets. I've stripped out everything else except the pages themselves, just to put our focus on facelets. This is a Maven based project, and you need Tomcat (or any servlet container) to run the resulting webapp. To begin with this is the list of files: ./pom.xml ./src/main/webapp/home.xhtml ./src... I left faces-config.xml in there for completeness sake, it may not be needed. The Maven POM ( pom.xml ): <?xml version="1.0" encoding="UTF-8"?> <project... Web app configuration ( WEB-INF/web.xml ): <?xml version="1.0" encoding="UTF-8"?> <web-app... Empty WEB-INF/faces-config.xml : <?xml version="1.0" encoding="UTF-8"?> <!-- Thi... index.jsp is simply a redirect to home.jsf : <% response.sendRedirect("home.jsf"); %>...
Created by Dr. Xi on November 23, 2010 20:20:01    Last update: March 01, 2011 13:38:51
I tried to find a GZIP compression servlet filter to compress a large log file that we send down to the browser. Most of the implementations I found were overly complicated and many buggy. This is a simple implementation that worked for me. The filter: package filter.demo; import java.io.*; i... Config web.xml : <filter> <filter-name>gzipFilter</filte... The ugly anonymous inner class could have been avoided if the servlet API did not insist on ServletResponse.getOutputStream returning the bogus ServletOutputStream class (instead of the plain OutputStream ). Additional Note: In an earlier version of this filter, the gzip headers were added in doFilter , like this: // This is NOT good! if (supportsGzip) { ... It turned out that the ServletResponse methods sendError bypasses the gzip...
Created by Dr. Xi on September 17, 2010 21:29:47    Last update: September 17, 2010 21:31:43
With JBoss (Tomcat?), the servlet container always appends the default charset ISO-8859-1 to the Content-Type header of a JSP response. For example, if you are using JSP to render PDF and put the following declaration at the top of the JSP: <%@ page contentType="application/pdf"%> These would be the headers in the HTTP response (notice that charset=ISO-8859-1 was appended to Content-Type ): HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-... And the output would be truncated a few bytes before non-ASCII characters were encountered, without any error messages ! Maybe you don't intend to output binary files with JSP, but still your response would be truncated without warning if the page happens to contain any non-ASCII characters (when the charset is the default charset=ISO-8859-1 ). However, if you...
Created by nogeek on April 25, 2010 05:09:14    Last update: April 25, 2010 05:10:46
Oracle Web Cache version used: Oracle Application Server Web Cache 10.1.2.3.0 ... The test page is a simple Struts action sending a URL redirect: public ActionForward execute(ActionMapping map... Web Cache setup Origin server Host Name Port oas.host 7777 Site Host Name Port URL Path Prefix webcache.host 80 Test results Request directly to the OC4J (Oracle Application Server): C:\work\testAppWebApp2>curl --dump-header - http:/... Request to Oracle Web Cache: C:\work\testAppWebApp2>curl --dump-header - http:/... Notice that Oracle Web Cache correctly translated the host name in the header and HTML page. However, the port number remained that of the Oracle App Server.
Created by Fang on September 07, 2009 16:39:37    Last update: September 07, 2009 18:43:04
It's easiest to use the archetype plugin to start a new Maven project. I'll use struts 1 as example since it's not in the built-in archetypes for archetype:generate . Generate a simple webapp with archetype:generate : C:\work\maven>mvn archetype:generate -DarchetypeAr... It generates a directory structure like this: struts1app struts1app/pom.xml struts1app/src... with a simple POM: <project xmlns="http://maven.apache.org/POM/4.0.0"... Create settings.xml in $HOME/.m2 , add Java.net repository for Java EE dependencies: <?xml version="1.0" encoding="UTF-8"?> <setting... Add Java EE and Struts dependencies in pom.xml . Note that the Java EE dependency has scope provided , meaning that the web app container provides the jars, therefore we don't need to bundle them with our war fie. <project xmlns="http://maven.apache.org/POM/4.0.0"... Create a directory named java under main , create the Struts form and...