create setenv.sh as follow and put it into $CANTLINA_HOME/bin
#!/bin/sh
JAVA_OPTS="-Xms256m -Xmx512m -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:MaxPermSize=256m"
#!/bin/sh
JAVA_OPTS="-Xms256m -Xmx512m -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:MaxPermSize=256m"
function uniqueSuffix() {
uniqueSuffix.counter = uniqueSuffix.counter || 0;
return uniqueSuffix.counter++;
}
uniqueSuffix();
uniqueSuffix();
console.log(uniqueSuffix.counter); // >>2
function dateValidator(text) {
var pattern = /^([1-9]\d{3})-(0[1-9]|1[0-2])-([0-2][1-9]|3[0-1])$/;
if (pattern.test($.trim(text))) {
var datePart = text.split('-');
var year = parseInt(datePart[0], 10);
var month = parseInt(datePart[1], 10) - 1;
var day = parseInt(datePart[2], 10);
var date = new Date(year, month, day, 0, 0, 0);
var y = date.getFullYear();
var m = date.getMonth();
var d = date.getDate();
if ( year == y && month== m && day == d) {
return true;
}
}
return false;
}
http://localhost:8080/myWebCtxt/purchase.do;jsessionid=4FB61319542B5D310B243E4BDD6DC64BAdding session ID to each and every link is cumbersome and hence is simplified by the following methods: response.encodeURL(givenURL) to associate a session ID with a given URL and if you are using redirection then response.encodeRedirectURL(givenURL).
public class CRMServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.getSession().setAttribute("key", "ItemNo-1245");
String url = resp.encodeURL("/myWebCtxt/purchase.do");
PrintWriter pw = resp.getWriter();
pw.println("Sample encoded URL -->purchase");
}
}
When you invoke the method encodeURL(givenURL) with the cookies turned on, then session ID is not appended to the URL. Now turn the cookies off and restart the browser. If you invoke the encodeURL(givenURL) with the cookies turned off, the session ID is automatically added to the URL as follows:http://localhost:8080/myWebCtxt/purchase.do;jsessionid=4FB61319542B5D310B243E4BDD6DC64B
When the user clicks the “Upload” button, the client browser locates the local file and sends it to the server using HTTP POST. When it reaches your server, your implementing servlet should process the POST data in order to extract the encoded file. Unfortunately, application servers implementing the Servlet and JSP specifications are not required to handle the multipart/form-data encoding. Fortunately there are number of libraries available such
//set the header to a non-standard value for attachments to be saved by the browser with the //Save-As dialog so that it is unrecognized by the browsers because often browsers try to do //something special when they recognize the content-type. response.setContentType(“application/x-download”); //use Content-Disposition “attachment” to invoke “Save As” dialog and “inline” for displaying //the file content on the browser without invoking the “Save As” dialog. response.setHeader(“Content-disposition”, “attachment;filename=” + fileName);
@RequestMapping(value = "get_zip_archive")
public ResponseEntity<byte[]> getZippedLogFilesArchive(@RequestParam("tempFileName") String tempFileName) throws IOException {
final File zipFile = new File(TEMP_DIR, tempFileName);
try {
final HttpHeaders headers = new HttpHeaders();
headers.set("Content-Disposition", "attachment; filename=" + tempFileName);
headers.setContentLength(zipFile.length());
return new ResponseEntity<byte[]>(Files.toByteArray(zipFile), headers, HttpStatus.OK);
} finally {
Files.deleteRecursively(zipFile);
}
}
function downloadReport(id) {
window.location = "downloadReportData?id=" + id;
}