Recent Notes
Displaying notes 31 - 40
Created by Dr. Xi on January 20, 2012 15:05:14
Last update: January 20, 2012 15:06:15
Tomcat documentation states:
If the web application is packaged as a WAR then /META-INF/context.xml will be copied to $CATALINA_BASE/conf/ [enginename] / [hostname] / and renamed to match the application's context path .
For a Maven project, put context.xml in src/main/webapp/META-INF/ .
Created by zhidao on January 18, 2012 12:03:32
Last update: January 18, 2012 12:03:32
I think this is simpler:
grep -l limit .*
Created by Fang on January 17, 2012 13:49:26
Last update: January 17, 2012 13:49:26
Some dependencies may not be available from the central Maven repository, or any public repository (for example, due to licensing issues). You can install these to your local repository with the Maven Install Plugin :
mvn install:install-file -Dfile=path-to-your-arti...
Only the file parameter is required.
Created by Dr. Xi on January 17, 2012 11:58:16
Last update: January 17, 2012 11:58:16
Steps to configure JavaMail resource for Tomcat 6 & 7:
Install JavaMail jar: download the JavaMail API , unzip the archive and copy mail.jar to $CATALINA_HOME/lib .
Add JavaMail resource to $CATALINA_BASE/conf/context.xml :
<?xml version="1.0"?>
<Context>
.
...
Add resource-ref for the JavaMail resource to your webapp WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app...
Use the JavaMail resource in your webapp:
// import javax.naming.*;
// import javax.mail....
Created by Fang on January 16, 2012 20:01:47
Last update: January 17, 2012 08:06:45
The behavior is weird. If you don't have jQuery Form Plugin loaded but use ajaxSubmit with jQuery validation, the form submits normally (i.e., not Ajax):
$('#myform').validate({
submitHandler: func...
In fact, you can use any junk as a function call, the script does not error out but submits the form non-Ajax way:
$('#myform').validate({
submitHandler: func...
Created by Fang on January 16, 2012 19:50:00
Last update: January 16, 2012 19:50:00
jQuery validation plugin hooks into the form submission cycle, so in order to submit a form via Ajax you have to use the submitHandler option of the validate method:
$('#myform').validate({
submitHandler: func...
Or, with jQuery Form Plugin:
$('#myform').validate({
submitHandler: func...
Created by Fang on January 16, 2012 19:32:20
Last update: January 16, 2012 19:32:54
You can submit a form via Ajax by the jQuery Form Plugin . There are two main methods:
ajaxForm : prepares a form for Ajax submit.
Example:
$('#myFormId').ajaxForm({
target: ...
When the form is submitted, it is sent via Ajax.
ajaxSubmit : submit a form via Ajax.
Example:
$('#myForm2').submit(function() {
// i...
jQuery Form Plugin is not in the core jQuery API, so you have to include an additional JS file:
<head>
<script type="text/javascript" ...
Created by Fang on January 16, 2012 15:34:15
Last update: January 16, 2012 15:34:15
Use the .serialize() method to encode the form data for Ajax call:
$.ajax({
url: 'formHandler',
data: $(t...
Created by Fang on January 16, 2012 13:03:28
Last update: January 16, 2012 14:58:13
Apache commons validator provides a class to validate emails.
Code:
import org.apache.commons.validator.EmailValidator...
Maven dependency:
<dependency>
<groupId>commons-validator</gr...
Created by Fang on January 16, 2012 13:29:00
Last update: January 16, 2012 13:29:00
According to RFC 4627 , the MIME content type for JSON is application/json :
The MIME media type for JSON text is application/j...
So, in Java code:
servletResponse.setContentType("application/json")...