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: joai-project   File:   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 2
Project: djpt   File:   View Source Code Vote up 5 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++){
		String NewFileName = new Date().getTime()+""+((char)((Math.random()*26)+97))+((char)((Math.random()*26)+97));
		String Ext = getImageExtFromBase64(files[i]);
		tmp_htext += NewFileName+"."+Ext+(i<files.length-1?";":"");
	return tmp_htext;
Example 3
Project: uavstack   File:   View Source Code Vote up 5 votes
private String getReqRealPath(HttpServletRequest request) {

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