servlets

java.io.FileNotFoundException when writing uploaded file to disk via getRealPath()

纵然是瞬间 提交于 2019-12-25 04:46:24
问题 Glassfish seems to be adding extra to the path I want to save my image file too, is there some way to use only the absolute path my servlet gets with String appPath = request.getServletContext().getRealPath(""); ? I have spent days trying different methods to upload an image file and have a servlet save it to disk. I used this example: http://www.codejava.net/java-ee/servlet/how-to-write-upload-file-servlet-with-servlet-30-api Using debug I can see the file name and path information is

Requesting to a servlet file downloading via ajax(no jquery please..)

我的梦境 提交于 2019-12-25 04:39:15
问题 The process is this: from web(jsp) I upload some pdf file(submitting via ajax) in the backend I merge these pdf I get the response(the merged pdf) via ajax --> start the file download... I'm having issues with the third step. I've included only the relevant code where I submit the file to upload (post request) and start the download. I put also a direct link, that calls the same steps in get method and works. Where is my problem? Thanks in advance... Here is the jsp body tag <a href="

Jquery: post data to a jsp method?

自古美人都是妖i 提交于 2019-12-25 04:23:08
问题 I am currently a asp.net guy, but have to do some jsp work now. I know that in asp.net, you can define a public static method with [WebMethod] attribute e.g. [WebMethod] public static string GetIt(string code) { return GetSomething(code); } then, I can call this method in jquery $.ajax({ type: "POST", url: "PageName.aspx/GetIt", data: "{'code':'+$("#code").val()+"'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { // Do something interesting here. }

Is it posible to change upload path with a servlet?

倾然丶 夕夏残阳落幕 提交于 2019-12-25 04:12:35
问题 I'm gonna try to explain what I want to do here and why I need to do it this way. I know I can redirect my inside of context paths to outside of context paths using a servlet like the next that I got somewhere around here, which works beautifully: @WebServlet("/images/*") public class ImageServlet extends HttpServlet { // Properties --------------------------------------------------------------------------------- private String imagePath; // Init ----------------------------------------------

404 error when running a GWT program in Eclipse. Seems to be to do with servlet mapping

你。 提交于 2019-12-25 04:09:19
问题 I have a GWT project which has been working fine for many weeks. On opening the code yesterday I found dozens of big red errors in my code. I've seen this happen before and have learnt, after much frustration, that all I need to is clean the project for Eclipse to be happy again, so I did that. Fine. However, when I run the thing, I get a 404 error saying this: type Status report message /LittleRedGarden/littleredgarden/greet description The requested resource (/LittleRedGarden

404 error when running a GWT program in Eclipse. Seems to be to do with servlet mapping

☆樱花仙子☆ 提交于 2019-12-25 04:08:51
问题 I have a GWT project which has been working fine for many weeks. On opening the code yesterday I found dozens of big red errors in my code. I've seen this happen before and have learnt, after much frustration, that all I need to is clean the project for Eclipse to be happy again, so I did that. Fine. However, when I run the thing, I get a 404 error saying this: type Status report message /LittleRedGarden/littleredgarden/greet description The requested resource (/LittleRedGarden

How is annotations support in jsp implemented in sitebricks?

那年仲夏 提交于 2019-12-25 03:47:16
问题 Here is an example from the SiteBricks user guide: <html> <body> @ShowIf(true) <----- I'm impressed with this line <p>${message} from Sitebricks!</p> </body> </html> I'm curious how is it implemented? (I mean how and at which entry point sitebricks creators managed to enhance transforming jsp to servlet?) Thanks for any ideas! 回答1: There is no filter doing this. We have our own templating logic that uses what is known as a recursive descent parser. It's actually a non-trivial problem to

Java compilation gives errors about servlet libraries

 ̄綄美尐妖づ 提交于 2019-12-25 03:39:35
问题 I am trying to compile a simple class that imports some servlet libraries. Since I have not added the tomcat directory to the classpath, what is the good practice way to let the system know where to look for the servlet libraries which are found in the tomcat/lib folder? Currently, the system just gives errors like this: ackage javax.servlet does not exist [javac] import javax.servlet.ServletException; 回答1: If you want to use only the java-provided tools, you will have to look at the JavaDocs

passing correct ip via linked docker containers from nginx to jetty

时光毁灭记忆、已成空白 提交于 2019-12-25 03:38:31
问题 I have two docker container running, one is a nginx that accepts http and https requests and passes them to the other one which is a jetty container. I have noticed an issue since I switched to docker. I can't get the right request IP. The jetty application checks the request IP to ensure requests are coming from a particular server. In the Servlet I use following code to get the IP: protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws

java- how to initialise session in second servlet (to get data stored by first servlet in session variable)

梦想与她 提交于 2019-12-25 03:28:25
问题 I am storing a variable in session data, from a servlet where the user tries logging in to my application. Now I want to retrieve the user data from session, in another servlet in the same application. How do I initialise the session variable in the second servlet? Taking "request" as the "HttpServletRequest" do I code the session variable as "HttpSession session = null;" or as "HttpSession session = request.getSession(true);"? Or is it some other way? Note that in the application flow, the