Recent Notes

Displaying keyword search results 1 - 10
Created by James on May 03, 2012 14:54:46    Last update: May 03, 2012 14:54:46
History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. For HTML4 browsers it will revert back to using the old onhashchange functionality. All major browsers are supported. This is a simple test page to get started: <html> <head> <title>Test History</title> ... Note: state url must be provided for IE to generate a unique hash. YOu can prefix the state url with '?' ('#' does not work).
Created by Dr. Xi on April 19, 2012 10:10:08    Last update: April 19, 2012 10:11:06
The default servlet for Tomcat is declared in $CATALINA_HOME/conf/web.xml : <servlet> <servlet-name>default</servle... Therefore, static content is rendered by the default configuration unless you override it with your own definitions. If you want to allow directory listing, just change the listing parameter to true : <init-param> <param-name>listings</para... Change the welcome-file-list to display a default page in lieu of a directory listing: <welcome-file-list> <welcome-file>home.xhtml</... Welcome pages are defined at the Web application level.
Created by Fang on April 16, 2012 13:32:10    Last update: April 16, 2012 13:32:10
There are two steps to create a custom function for JSP: Declare the function in the TLD: <?xml version="1.0" encoding="UTF-8" ?> <taglib... Implement the function (must be static): package com.example; public class UrlTransl... To use the function: <%@ taglib uri="http://www.example.com/jsp/tags" p...
Created by Fang on February 24, 2012 14:38:06    Last update: April 06, 2012 13:19:29
Step 1: create a Json factory: package com.my.service.dev; import java.io.... Step 2: use it: ObjectMapper mapper = new ObjectMapper(new AllowCo...
Created by Fang on March 30, 2012 15:04:04    Last update: March 30, 2012 15:04:04
Spring MVC 3.1 can send either JSON or HTML response on the same URL, depending on the type of response requested. With this mechanism, a page can be sent when directly requested from a link, but a JSON response can be sent in response to an AJAX request. This is the controller code: package com.example; import java.util.Map; ... In the above example, JSON response will be sent when the HTTP request contains header "Accept: application/json". HTML response will be sent then the header is "Accept: */*", or "Accept: text/html", or anything else. You can add a limitation that the HTML response does not produce "application/json". But then the question is which response will be sent when the HTTP header is "Accept: */*"? Both methods will...
Created by Fang on March 30, 2012 12:15:49    Last update: March 30, 2012 12:15:49
1. mvc:default-servlet-handler Configures a handler for serving static resources by forwarding to the Servlet container's default Servlet. Use of this handler allows using a "/" mapping with the DispatcherServlet while still utilizing the Servlet container to serve static resources. HandlerMapping: org.springframework.web.servlet.handler.SimpleUrlHandlerMapping Handler: org.springframework.web.servlet.handler.SimpleUrlHandlerMapping Attribute Description default-servlet-name The name of the default Servlet to forward to for static resource requests. The handler will try to auto-detect the container's default Servlet at startup time using a list of known names. If the default Servlet cannot be detected because of using an unknown container or because it has been manually configured, the servlet name must be set explicitly. 2. mvc:view-controller Defines a simple Controller that selects a view to render the response. HandlerMapping: org.springframework.web.servlet.handler.SimpleUrlHandlerMapping Handler: org.springframework.web.servlet.mvc.ParameterizableViewController Attribute Description...
Created by magnum on July 26, 2010 15:55:41    Last update: March 28, 2012 15:28:02
Given the URL: http://www.mydomain.com/myWebApp/theServlet/p1/p2/p3;sid=123?param=abc This would be the output of the various method calls on HttpServletRequest : String scheme = request.getScheme(); // ...
Created by nogeek on March 13, 2012 11:53:49    Last update: March 13, 2012 11:53:49
A. To configure Apache httpd to proxy Tomcat using HTTP: Load Apache httpd modules ( httpd.conf ): LoadModule proxy_module /usr/lib/apache2/modules/m... Configure Apache httpd proxy: <VirtualHost *:80> ServerAdmin webmaster@my... Configure Tomcat HTTP connector with appropriate proxyName and proxyPort : <Connector port="8080" protocol="HTTP/1.1"... Note: context path must be the same for httpd and Tomcat. B. To configure Apache httpd to proxy Tomcat using AJP: Load Apache httpd modules ( httpd.conf ): LoadModule proxy_module /usr/lib/apache2/modules/m... Configure Apache httpd proxy: <VirtualHost *:80> ServerAdmin webmaster@my... Configure Tomcat AJP connector: <Connector port="8009" protocol="AJP/1.3" redirect... You can try this if context path must be changed between Tomcat and httpd: <VirtualHost *:80> ServerAdmin webmaster@my... But this may not work in case the servlet context path is written in the HTML content. ProxyPassReverse only...
Created by Dr. Xi on March 13, 2012 08:46:57    Last update: March 13, 2012 08:46:57
This trick sets HTML base to the root context path of the current webapp: The short version: <!DOCTYPE html> <%@ taglib uri="http://java.sun... The long version: <!DOCTYPE html> <%@ taglib uri="http://java.sun...
Created by Dr. Xi on March 08, 2012 09:16:02    Last update: March 08, 2012 09:16:02
In my JSP there's a link like this: <a href="/path/${part1}/${part2}">the link</a> where part1 and part2 may contain characters that need to be URL encoded (such as '#'). JSP JSTL does not provide such facility out of the box. But there's a hack using <c:url> , or you can use <spring:url> : JSTL hack: <c:url value="/path" var="theUrl"> <c:param... Using Spring url tag: <spring:url value="/path/{part1}/{part2}" var="enc...
Previous  1 2 3 4 5 6 7 8 9 10 Next