Seeking assistance with passing a variable from a scriptlet in one jsp to the 'calling jsp'
The scenario involves assetedit.jsp posting a binary stream to upload.jsp. However, despite the processing of the stream in upload.jsp and determination of a filepath, I am unable to access this value in assetedit.jsp as it returns null pointer.
I have attempted various solutions, including using asynchronous calls within the post method to potentially slow down the process, but nothing seems to work.
Your thoughts on the matter would be greatly appreciated.
Snippet of assetedit.jsp -
//post binary to upload.jsp
$.ajax({
url: '/wz/upload.jsp',
data: decodedstring,
type: 'POST',
contentType: false,
processData: false,
}).done(function(data) {
console.log(data);
});
Partial code from upload.jsp (for clarity) -
<%
try {
String root = getServletContext().getRealPath("/uploads/");
BufferedInputStream bis = new BufferedInputStream(request.getInputStream());
String nm = System.currentTimeMillis() + ".jpg";
String filepath = root + "/" + nm;
String realpath = (filepath.substring(filepath.lastIndexOf("/") - 7));
System.out.println("realpath is " + realpath);
pageContext.setAttribute("pathtogo", realpath);
}
fos.close();
bis.close();
);
} catch (Exception ex) {
ex.printStackTrace();
}
%>
Another snippet from assetedit.jsp -
<%
String str = request.getAttribute("pathtogo").toString();
System.out.println("pathtogo is " + str);
%>
Additional attempt made in assetedit.jsp -
<%
String name=(pageContext.getAttribute("pathtogo").toString());
System.out.println("pathtogo is "+name);
%>
However, these attempts result in an error - Uncaught TypeError: getElemRefs(...) is null
I welcome any suggestions or insights on whether another post action in upload.jsp is needed to send pathtogo back to assetedit.jsp?
Thanks for your help,