This content has been marked as final. Show 3 replies
I think, though am not certain, that in order to do this you would need to first create a second web application, then in the first servlet create a ServletContext that references the second. And use that when you call getRealPath().
"There is one context per "web application" per Java Virtual Machine."
Have a closer look at the ServletContext API.
I think, yet again, that when you're hard coding you're absolute path (not a good idea) the resource you're referring to is not in the current Servlets context, hence is unavailable.
I'm probably all wrong though.
The servlets forum is the better place to post this question.
That's nothing to do with java.io.File or pathnames or any of the things your post was talking about.
2006-02-03 12:12:05 StandardWrapperValve[jsp]: Servlet.service() for servlet jspLook closely at the stack trace: Unterminated <% tag is the message. org.apache.jasper.compiler is the package of the class with the problem. That means your JSP doesn't compile because of a syntax error. Most likely you are missing one of the two " characters that delimit a string, so your %> closing tag looks like part of the string.
org.apache.jasper.JasperException: /upload.jsp(11,2) Unterminated <% tag
at org.apache.jasper.compiler.DefaultErrorHandler.jspErro r(DefaultErrorH andler.java:39)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(Er rorDispatcher.j ava:409)
This is just one of the many reasons you shouldn't be putting code like this into JSPs.
Thanks. I must have deleted the "%>" by accident while I was fiddling with the code (this is what happens when you look at the same code for too long!!). That explains why File savedFile = new File("/usr/local/tomcat/webapps/mywebapp/uploads", fullFile.getName()); didn't work earlier. Now it does.
However, the following still does not work:
ile savedFile = new File("/absolute/path/to/another/context/uploads", fullFile.getName());
This is the stack trace:
Generated servlet error:
pache/jsp/upload_jsp.java:39: 'try' without 'catch' or 'finally'
Generated servlet error:
pache/jsp/upload_jsp.java:109: '}' expected
Do you know what the problem could be?
I will try sroot's suggestions to reference another servletcontext...though the place where I'd like to put the "/uploads" folder isn't a web application, but just a directory on my server....
Thanks for your help; online forums are a life-saver!!!
That means your JSP
doesn't compile because of a syntax error. Most
likely you are missing one of the two " characters
that delimit a string, so your %> closing tag looks
like part of the string.