servlets

jQuery.ajax servlet return a file [duplicate]

不想你离开。 提交于 2020-01-02 18:04:06
问题 This question already has an answer here : How to download file from httpServlet with Jquery? (1 answer) Closed 2 years ago . I'm pretty new to jQuery and ajax and i have a question. In a jsp I call function downloadDocument(documentId){ var action = "attachment.do"; var method = "downloadDocument"; var url = action + "?actionType="+method+"&documentId=" + documentId; $.ajax({ url: url, dataType: "json", type: 'POST', success: function(data){ alert("downloaded!"); }, error: function (request,

Handling the browser 'Back' button in jsp

*爱你&永不变心* 提交于 2020-01-02 17:19:22
问题 I have a jsp search page (Search.jsp) and a result page (Result.jsp), both of them can choose search criteria. and then passed the parameters to a java controller file (Controller.java) to build a query string and performs query searching. The query string and searched results will be passed to Result.jsp for displaying. Currently I use servletContext to remember the processed query string, and if users use Result.jsp to select search criteria, Controller.java will append such criteria to the

How to stop re submitting a form after clicking back button [duplicate]

元气小坏坏 提交于 2020-01-02 13:10:53
问题 This question already has answers here : Prevent user from seeing previously visited secured page after logout (5 answers) Closed 3 years ago . I have a JSP page with a form where you fill up certain details. On submitting the form i call a servlet which then updates details in a database after that i redirect to a page i display a confirmation message to the user. The problem i have here is when the user clicks back he goes to the form page again where if he clicks a submit button, it

encoding gets messed up when including file input in form

扶醉桌前 提交于 2020-01-02 12:21:06
问题 I'm having an issue with the encoding of input from form elements being messed up when I include a file input in my form. I'm using jquery and a servlet backend(and ajax call), but I dont see how this should have anything to do with it. HTML page encoding is set to UTF-8, and I specify the character encoding for the servlet request to use utf8 as well. When I remove the file input from the form, the encoding is allright. When I investigate the headers for the request I see the following

Redirect jsp from jsp - error “The requested resource is not available.” [duplicate]

谁说胖子不能爱 提交于 2020-01-02 10:30:11
问题 This question already has answers here : Send redirect to relative path in JSP? (3 answers) Closed 3 years ago . I'm working on a social networking site and I have the following problem. In profile.jsp I have a form where the user can upload a photo. This form has an action to FileUploadHandler servlet which uploads the photo and then sends redirect to uploadfileController.jsp like this: RequestDispatcher requestDispatcher; requestDispatcher = request.getRequestDispatcher("

Java overloaded method in library fails when not run in web server

橙三吉。 提交于 2020-01-02 09:41:53
问题 I am trying to write a small library that can either be used in a standard java app or as part of a servlet. I have defined a couple of overloaded methods as follows: // imports etc. public ExampleLibrary { /** * This one is meant to be used by a J2SE app */ public String processData(Map headers) throws MyException { // process // return result } /** * This one is meant to be used by a servlet */ public String processData(HttpServletRequest request) throws MyException { // extract headers

Java overloaded method in library fails when not run in web server

霸气de小男生 提交于 2020-01-02 09:41:37
问题 I am trying to write a small library that can either be used in a standard java app or as part of a servlet. I have defined a couple of overloaded methods as follows: // imports etc. public ExampleLibrary { /** * This one is meant to be used by a J2SE app */ public String processData(Map headers) throws MyException { // process // return result } /** * This one is meant to be used by a servlet */ public String processData(HttpServletRequest request) throws MyException { // extract headers

Asynchronous servlet not acting asynchronously

情到浓时终转凉″ 提交于 2020-01-02 07:32:12
问题 I have a servlet that takes a request and writes a long response. The response is in a loop that uses Thread.sleep(1000) to simulate a long running operation. I am trying to setup an asynchronous request here, as shown in code. But it is not working. When i invoke several requests to the servlet, they all execute consecutively, not at the same time. What am i doing wrong? And i though servlets are supposed to be threaded - each request to server causes the container to execute a new thread

java.lang.NullPointerException Hibernate used with Ehcache

穿精又带淫゛_ 提交于 2020-01-02 07:23:22
问题 I used Hibernate 4.1.2 with Ehcache 2.4.3 (shipped together with hibernate when donwloaded hibernate). My hibernate.cfg.xml : <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class"> com.microsoft.sqlserver.jdbc.SQLServerDriver </property> <property name=

How to obtain an HttpSession Object from SessionID?

拈花ヽ惹草 提交于 2020-01-02 06:35:34
问题 I want to invalidate sessions of users based on some Event. I store their sessionID, how to get their HttpSession from this ID? The HttpSessionContext class is deprecated with no replacement. 回答1: Servlet 2.2 specifically deprecated this for security reasons so there shouldn't be any official way to do this. Not recommended but you can can try to use Manager.findSession() if you use Tomcat. I just removed HttpSession from my application. It's really hard to keep sessions in sync when many