This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.test; | |
| import java.io.Serializable; | |
| public class Singleton implements Serializable | |
| { | |
| private static final long serialVersionUID = 1L; | |
| private static Singleton s = null; | |
| // to block instantiation by others |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.test; | |
| import java.io.FileInputStream; | |
| import java.io.FileNotFoundException; | |
| import java.io.FileOutputStream; | |
| import java.io.IOException; | |
| import java.io.ObjectInputStream; | |
| import java.io.ObjectOutputStream; | |
| public class SingletonTest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.test; | |
| public class SingletonTest | |
| { | |
| public static void main(String[] args) | |
| { | |
| Singleton s1 = Singleton.getInstance(); | |
| Singleton s2 = Singleton.getInstance(); | |
| try | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.test; | |
| import java.io.Serializable; | |
| public class Singleton implements Serializable | |
| { | |
| private static final long serialVersionUID = 1L; | |
| private static Singleton s = null; | |
| // to block instantiation by others |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int monthNameToDays(String s, int year) | |
| { | |
| switch(s) | |
| { | |
| case "April": | |
| case "June": | |
| case "September": | |
| case "November": | |
| return 30; | |
| case "January": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int monthNameToDays(String s, int year) | |
| { | |
| if(s.equals("April") || s.equals("June") || | |
| s.equals("September") || s.equals("November")) | |
| return 30; | |
| if(s.equals("January") || s.equals("March") || | |
| s.equals("May") || s.equals("July") || | |
| s.equals("August") || s.equals("December")) | |
| return 31; | |
| if(s.equals("February")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/"> | |
| <appender class="org.apache.log4j.RollingFileAppender" name="ROLL"> | |
| <param name="Threshold" value="DEBUG" /><param name="File" value="${catalina.base}/logs/my.log" /> | |
| <param name="Append" value="true" /><param name="MaxFileSize" value="1MB" /><param name="MaxBackupIndex" value="5" /><layout class="org.apache.log4j.PatternLayout"> | |
| <param name="ConversionPattern" value="%d %-5p [%c] %m%n" /></layout> | |
| </appender> | |
| <appender class="org.apache.log4j.ConsoleAppender" name="CONSOLE"> | |
| <param name="Target" value="System.out" /><param name="Threshold" value="DEBUG" /><layout class="org.apache.log4j.PatternLayout"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var options = { | |
| dataType: 'json', | |
| success: processResponse | |
| }; | |
| $('#upload_form_id').ajaxForm(options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if ((null != req.getHeader("Accept")) | |
| && req.getHeader("Accept").contains("application/json")) | |
| { | |
| resp.setContentType("application/json"); | |
| } | |
| else | |
| { | |
| resp.setContentType("text/plain"); | |
| } | |
| resp.getWriter().write(jsonResponse); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // are there files to upload? | |
| var fileInputs = $('input:file', this).length > 0; | |
| var mp = 'multipart/form-data'; | |
| var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); | |
| // options.iframe allows user to force iframe mode | |
| // 06-NOV-09: now defaulting to iframe mode if file input is detected | |
| if (options.iframe !== false && (fileInputs || options.iframe || multipart)) { | |
| // hack to fix Safari hang (thanks to Tim Molendijk for this) | |
| // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d |