Java Code Examples for javax.servlet.http.HttpServletRequest.getRealPath()

The following are Jave code examples for showing how to use getRealPath() of the javax.servlet.http.HttpServletRequest class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: djpt   File: MyBase64.java   View Source Code Vote up 6 votes
public static String dealWithBase64(HttpServletRequest request, String files[]) {
	String tmp_htext = "";
	String upload_path = request.getRealPath("/uploads");
	for(int i=0;i<files.length;i++){
		if(files[i]==null)continue;
		String NewFileName = new Date().getTime()+""+((char)((Math.random()*26)+97))+((char)((Math.random()*26)+97));
		String Ext = getImageExtFromBase64(files[i]);
		generateImage(files[i],upload_path,NewFileName,Ext);
		tmp_htext += NewFileName+"."+Ext+(i<files.length-1?";":"");
	}
	return tmp_htext;
}
 
Example 2
Project: joai-project   File: JspFunctions.java   View Source Code Vote up 5 votes
/**
 *  Finds a file relative to the jsp page in which the function is called.
 *
 * @param  relativePath  NOT YET DOCUMENTED
 * @param  request       NOT YET DOCUMENTED
 * @return               The file value
 */
private static File getFile(String relativePath, HttpServletRequest request) {
	String servletPath = request.getServletPath();
	String realPath = request.getRealPath(servletPath);
	File dir = new File(realPath).getParentFile();
	File file = new File(dir, relativePath);
	return file;
}
 
Example 3
Project: uavstack   File: JEEServiceRunGlobalFilterHandler.java   View Source Code Vote up 5 votes
@SuppressWarnings("deprecation")
private String getReqRealPath(HttpServletRequest request) {

    try {
        return request.getServletContext().getRealPath("");
    }
    catch (Error e) {
        return request.getRealPath("");
    }
}