servlets

dynamic web project: “java.lang.ClassNotFoundException” despite .jar file in the WEB-INF/lib directory

a 夏天 提交于 2019-12-25 05:32:17
问题 I'm working on an assignment that requires some .jar files. The assignment requires me to do some work on a Tomcat servlet with JSP files. I included my .jars in the Java Build Path in Eclipse, and copied/added them to the WEB-INF/lib directory. When I run the project like so: http://localhost:8080/project/ I see the index.jsp page with empty divs where data should be from the code executed via the TestServlet.java . Looking for the reason why, I see the following error when I check out http:

How to not write HTML code in Servlet in case of Ajax [duplicate]

本小妞迷上赌 提交于 2019-12-25 05:31:44
问题 This question already has answers here : How to use Servlets and Ajax? (7 answers) Closed 3 years ago . I was told that writing HTML to the response.getWriter() in a Servlet is not a good practice and thats why JSP comes into picture. But in case of Ajax what I have seen is that I have to write HTML to the response.getWriter() in a Servlet for it to be picked by responseText property of the XMLHttpRequest object in the JSP. Is there any other way for Ajax to accomplish the same task? This is

Accessing local filesystem on the server from a servlet

我的未来我决定 提交于 2019-12-25 05:28:11
问题 I need to access an external directory (which contains some logs of a different application) from my servlet. From what I've seen all the file paths are resolved from the servlet context. How can I access files outside the servlet? 回答1: You can provide a full path when opening a given file so you can just do that if supported by your servlet container (most do). Note that accessing the underlying file system is making your application dependent on behavior not guaranteed to work by the

Sitebricks and Channel Presence Service (GAE); Also having trouble with normal servlets

南楼画角 提交于 2019-12-25 05:25:15
问题 In my Java Google App Engine server application, I would like to enable Channel Presence servlets in order to track connections/disconnections to/from my channels using the Channel API (as described here. I have already edited my WEB-INF/appengine-web.xml file like described. Most servlets in my application use Sitebricks , instead of classes extending HttpServlet, to provide an easy way for me to create REST endpoints in my app. BUT, it seems like using Sitebricks in my class, like so, does

Java/Tomcat: ServletContext & getResourceAsStream Problems

北城以北 提交于 2019-12-25 05:23:09
问题 I am trying to access a conf file (located in the WEB-INF folder) from a Tomcat web app. At the moment, I have the location of the file hard coded as a String . However, this does not work when the tomcat/webapps folder is in a different location than my hard coded String indicates. I've looked online and it seems like using the getResourceAsStream () method is what I'm looking for, but I'm having a hard time getting it to work. My application is not liking it when I call the

printing servlet request attributes with expression language

六月ゝ 毕业季﹏ 提交于 2019-12-25 05:16:21
问题 I want to print servlet request attributes within a JSP file use expression language. I have done the following, in my Servlet I set all the necessary request attributes with setRequestAttributes(String, Object); In my JSP page I use the following line to print the attribute: <c:out value="${string}"/> After reading other posts I checked if version 2.4 is used in the web XML, it is. When using getAttribute(String) In the Servlet itself it prints the value just fine. Does anyone have any idea

Status of the process triggered by request in java

女生的网名这么多〃 提交于 2019-12-25 05:06:14
问题 Is it possible to get the status of the process triggered by a request. Suppose, I have a request, that will trigger the long running process, like copying some files in the server side, or some other really long running process. Now I want to show user about the percentage completion of that task. How to do it in Java Servlet, or any other frame which supports this? What I thought was sending the continous response to the page. But this may not be possible. Please help me with this problem.

error 404 ,servlet not found with Tomcat [duplicate]

一世执手 提交于 2019-12-25 05:05:07
问题 This question already has answers here : Servlet returns “HTTP Status 404 The requested resource (/servlet) is not available” (10 answers) Closed 3 years ago . i want to write a simple servlet in my maven project but i'm getting this error the requested url (/src/main/java/web.servlets.FunctionalTestServlet) was not found on this server. here's my code : Servlet: located in src/main/java package web.servlets; import java.io.IOException; import java.io.PrintWriter; import javax.servlet

Java : download file outside server context

自古美人都是妖i 提交于 2019-12-25 04:59:15
问题 I need to save a file and download file in directory outside server context. I am using Apache Tomacat I am able to do this in directory present in webapps directory of application If my directory structure is as follows, --src --WebContent -- uploaddir -- myfile.txt Then I am able to download in by simply. <a href="uploaddir/myfile.txt" target="_blank">download</a> But, problem is when file is in some other directory say d:\\uploadedfile\\myfile.txt then I wont be able to download it, as

java.lang.IllegalStateException: Not Suspended when AsyncContext#complete()

末鹿安然 提交于 2019-12-25 04:47:51
问题 sometimes my Servlet ends with this exception: WARNING: StandardWrapperValve[HeartBeatServlet]: PWC1406: Servlet.service() for servlet HeartBeatServlet threw exception java.lang.IllegalStateException: Not Suspended at com.sun.grizzly.tcp.Response.resume(Response.java:768) at org.apache.catalina.connector.Request.asyncComplete(Request.java:3993) at org.apache.catalina.connector.AsyncContextImpl.complete(AsyncContextImpl.java:242) at com.northcane.talkeen.HeartBeatServlet.doPost