Recent Notes

Displaying keyword search results 71 - 80
Created by Fang on April 01, 2010 22:24:58    Last update: April 02, 2010 02:49:38
In this note I'll show you how to create and package a JSP custom tag. The purpose of this tag is to display a random splash image for a home page, among a set of images. We should be able to add or delete candidate splash images from the WAR archive without the need to change the JSP. This is the intended use of the tag: <%@ taglib uri="http://custom.tag.com/demo" prefix... In the above example you provide a set of images named splash*.png (e.g., splash1.png, spalsh2.png, ...), and the tag will pick a random one to display when the JSP is rendered. Let's get started. I'll use Maven for this purpose. Create the standard Maven directory structure ./pom.xml ./src ./src/main ./src/main/jav... pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0"... SplashTag.java package tagdemo; import java.util.ArrayList......
Created by Fang on March 23, 2010 02:33:54    Last update: March 31, 2010 04:16:40
Expression Language (EL) was introduced since JSTL 1.0, it is part of the JSP spec since JSP 2.0/JSTL 1.1. There's no JSTL without EL. But don't let the name scare you, EL is not another programming language. It's just a simple construct: ${expr} , which means that instead of taking expr literally, it should be evaluated in the page using any page/request/session/application variables exposed to that page. For example, if you put Hello ${world}! in your JSP, world will be evaluated in the page context. If you had set a value for world before, for example, request.setAttribute("world", "John Doe"); in your Struts action class or a servlet, the JSP page would show: Hello John Doe! There were confusions about EL support in various servlet/JSP/JSTL version...
Created by nogeek on March 21, 2010 20:30:53    Last update: March 21, 2010 20:37:53
Port 8080 is undoubtedly overused. You may want to change JBOSS to a port other than the default 8080. Edit the file $JBOSS_HOME/server/default/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml and change the webserver port from 8080 to 8088: <bean class="org.jboss.services.bi... The XSLT at the bottom of the file transforms port 8080 in $JBOSS_HOME/server/default/deploy/jbossweb.sar/server.xml to 8088 specified in this file.
Created by Dr. Xi on February 12, 2010 22:39:15    Last update: February 12, 2010 22:39:15
When you start Tomcat for the first time, you may get the "port 8080 is already in use" error. Indeed, port 8080 is commonly used by a lot of development servers by default (Oracle XE for another example). Luckily, it's quite easy to ask Tomcat to use a different port. I use port 8086, which is a natural next step and superior to 8080. Simply edit $CATALINA_BASE/conf/server.xml and change 8080 to 8086: <!-- A "Connector" represents an endpoint by w... If you have not configured Tomcat 6 for multiple instances by setting a CATALINA_BASE directory, then $CATALINA_BASE will be set to the value of $CATALINA_HOME , the directory into which you have installed Tomcat 6.
Created by Dr. Xi on February 11, 2010 00:04:02    Last update: February 11, 2010 00:04:02
Servlet container initializes this servlet when it starts up. The content of this element must be a positive integer indicating the order in which the servlet should be loaded. Lower integers are loaded before higher integers. If no value is specified, or if the value specified is not a positive integer, the servlet can be loaded in any order in the startup sequence. In this example, Struts is loaded before cms: <!-- Struts action servlet setup --> ...
Created by Dr. Xi on February 10, 2010 23:48:23    Last update: February 10, 2010 23:49:13
Servlet mapping examples in web.xml. Struts: <!-- Struts action servlet setup --> ... Spring: <servlet> <servlet-name>springapp</... JSF myfaces: <servlet> <servlet-name>Faces Servl...
Created by Dr. Xi on February 10, 2010 23:39:37    Last update: February 10, 2010 23:39:37
Example web.xml that includes most frequently used elements. This sample is for Servlet Specification 2.4. <?xml version="1.0" encoding="UTF-8"?> <web-ap...
Created by Fang on August 22, 2009 21:48:12    Last update: January 10, 2010 00:29:08
The POM (Project Object Model, pom.xml ) is at the heart of all Maven builds. It tells Maven how to build your project, just like build.xml for Ant. This is a POM for a simple Hello World project: <project xmlns="http://maven.apache.org/POM/4.0.0"... Not much can be inferred from the POM file alone, because lots of information is implied . For example, packaging defaults to jar , which means that if nothing is specified, Maven compiles all java files under src/main/java and creates a jar . All Maven POMs inherit from a base Super POM. To see the effective POM for your project, type mvn help:effective-pom : C:\maven\hello-world>mvn help:effective-pom Below is the Super POM for Maven 2.0.x. <project> <modelVersion>4.0.0</modelVersion> ...
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...
Created by Dr. Xi on April 30, 2009 23:26:13    Last update: May 01, 2009 17:08:49
ApplicationResources.properties contains these keys: test.key.1 = Test Key One test.key.2 = Test Key... Struts (struts-el): <%@ page contentType="text/html;charset=UTF-8" lan... JSTL <%@ page contentType="text/html;charset=UTF-8" lan... However, the values for one and two must be passed in from pageScope , requestScope , sessionScope , etc. Values defined by struts bean:define are not interpreted. Important: JSTL tags work with servlet spec 2.4 only. So your web.xml must start with this: <?xml version = '1.0' encoding = 'windows-1252'?> ... Not this: <?xml version = '1.0' encoding = 'windows-1252'?> ... However, the latter does work with struts-el tags.
Previous  1 2 3 4 5 6 7 8 9 Next