Recent Notes

Displaying keyword search results 1 - 10
Created by Fang on January 31, 2012 15:40:34    Last update: January 31, 2012 15:41:28
This is a simple Hello World application with Spring 3 MVC. Like the default Apache HTTPd welcome page, it displays " It works! " when successfully deployed. The sole purpose is to show the minimum elements needed to setup Spring 3 MVC. I use Maven since it's so much easier than downloading the dependencies manually. Directory layout: ./src ./src/main ./src/main/webapp ./src/... pom.xml : <?xml version="1.0" encoding="UTF-8"?> <project... WEB-INF/web.xml : <?xml version="1.0" encoding="UTF-8"?> <web-app... WEB-INF/applicationContext.xml (empty, but needed): <?xml version="1.0" encoding="UTF-8"?> <beans x... WEB-INF/spring-servlet.xml : <?xml version="1.0" encoding="UTF-8"?> <beans x... WEB-INF/jsp/home.jsp : <!DOCTYPE html> <html> <head> <title>H... Build with: mvn clean package The resulting webapp is target/springmvc.war .
Created by freyo on April 01, 2011 14:29:25    Last update: June 29, 2011 13:58:27
Start the emulator ( create an AVD if none exists) $ tools/emulator -avd Simple8 Create new project $ tools/android create project \ > --package co... where " --target 2 " identifies the target platform as displayed by " tools/android list targets ", which is stored in the properties file default.properties in the project root folder. cd HelloWorld and install debug package onto the running emulator: $ ant install Buildfile: build.xml [set... Launch the Hello World application on the emulator. You'll see something like this: Edit res/values/string.xml , change the contents to: <?xml version="1.0" encoding="utf-8"?> <resourc... Edit res/layout/main.xml , change the contents to: <?xml version="1.0" encoding="utf-8"?> <LinearL... The contents of the text area now refer to a string defined in the resource file strings.xml , instead...
Created by freyo on April 12, 2011 15:13:32    Last update: May 03, 2011 15:20:55
Create new project $ tools/android create project \ > --package co... Edit res/values/string.xml , add strings for the main screen. <?xml version="1.0" encoding="utf-8"?> <resourc... Add widgets to main layout ( res/layout/main.xml ). <?xml version="1.0" encoding="utf-8"?> <LinearL... Edit src/com/android/apkinfo/GetAPKPermissions.java and change contents to: package com.android.apkinfo; import android... Install the debug package to the emulator: ant install The screen should look like: Add display permissions activity. Start by creating a new layout res/layout/display_permissions.xml : <?xml version="1.0" encoding="utf-8"?> <LinearL... Add the strings used by the new Activity ( res/values/strings.xml ): <?xml version="1.0" encoding="utf-8"?> <resourc... Add the Display Permissions Activity ( src/com/android/apkinfo/DisplayPermissions.java ): package com.android.apkinfo; import android... Change src/com/android/apkinfo/GetAPKPermissions.java to invoke the Display Permissions Activity: package com.android.apkinfo; import android... Declare Display Permissions Activity in AndroidManifest.xml : <?xml version="1.0" encoding="utf-8"?> <manifes......
Created by freyo on April 18, 2011 15:08:21    Last update: April 18, 2011 15:12:20
Generate android project $ ~/android-sdk-linux_86/tools/android create proj... Create XML file res/xml/books.xml : <?xml version="1.0"?> <catalog> <book id=... Edit layout ( res/layout/main.xml ): <?xml version="1.0" encoding="utf-8"?> <Lin... Edit code ( src/com/android/xmlres/XMLResource.java ): package com.android.xmlres; import java.io.... Change activity label from app_name to booklist ( AndroidManifest.xml ): <?xml version="1.0" encoding="utf-8"?> <manifes... Add value for string resource ( res/values/string.xml ): <?xml version="1.0" encoding="utf-8"?> <resourc... Deploy and test: ant install
Created by voodoo on April 13, 2011 13:47:34    Last update: April 13, 2011 13:49:20
You get "permission denied" error from Apache HTTPD for a page. And you checked file/directory permissions (the whole directory path, not just the file) and everything in httpd.conf . If everything seemed right, then SELinux may be blocking the access. Open /var/log/httpd/error_log , you may see a line like this: [Wed Apr 13 15:50:35 2011] [notice] SELinux poli... These are the steps to fix: If the directory resides in a user home directory: # setsebool -P httpd_read_user_content 1 Create a policy package from the audit log: # grep httpd /var/log/audit/audit.log | audit2allo... Apply the policy package just created # semodule -i mypol.pp Restart apache httpd: # apachectl restart
Created by Fang on April 02, 2010 21:45:47    Last update: July 17, 2010 02:55:06
This is built upon the simple test application for JSTL , which contained a single servlet and a single JSP page. If I want to use it to test all available JSTL tags, the servlet and JSP page would be too complicated. Instead, I want to group the JSTL tags into separate JSP pages and display each group based on the requested URL. For example, if the URL ends with /CoreBasic , I'll display a page that contains the basic core tags; if the URL ends with /I18N , I'll display a page that contains the internationalization tags (e.g., <fmt:message> ). Furthermore, I want to delegate the handling of each group of tags to separate Java classes. This is the application I'll use for the...
Created by voodoo on June 17, 2010 15:23:02    Last update: June 17, 2010 15:35:40
Use useradd to add a user (the switches are not required, but it's a good idea to give them. For example, without -m you'd create a user without a home directory): # -d switch specifies user home directory # -m ... You also need to use the passwd command to set a new password before the user can log in. To delete a user, use the userdel command: userdel demo
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 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 October 06, 2008 18:39:53    Last update: October 06, 2008 18:39:53
Python modules are searched in the list of directories given by the variable sys.path which is initialized from: the directory containing the input script (or the current directory) the list of directories specified by the environment variable PYTHONPATH the installation-dependent default. peaches@bashful:~/tmp$ export PYTHONPATH=`pwd` ...
Previous  1 2 Next