servlets

unable to retrieve the passed value from jsp to controller using url via a button

人盡茶涼 提交于 2019-12-25 02:13:24
问题 I am assigning href to a button and passing a value to the controller JSP page <td><a href="viewController?book_id=<%=vo.getBookId()%>"><input type="button" name="remove" value="DELETE"/></a> </td> In controller, I am trying to get the value when the button is clicked using: if(request.getParameter("remove") !=null) { int cart_id=(Integer)request.getSession(false).getAttribute("cartid"); b_id = (String) request.getParameter("book_id"); int bid=Integer.parseInt(b_id); System.out.println(bid);

move tomcat webapp from server to localhost

萝らか妹 提交于 2019-12-25 01:54:23
问题 We, in the organization, have a web app currently running on a server. I want to move this app to my local machine where I can customize and edit files safely. I copied the app directory, let us name it 'mproject', to my local machine and added it to the webapps folder of tomcat. However, the app did not work. Tomcat gives me this error FAIL - Application at context path [/mproject] could not be started What parameters shall I modify in order to run this app on my local tomcat? Thanks in

Tomcat deploying troubles

让人想犯罪 __ 提交于 2019-12-25 01:54:02
问题 I'm trying to run servlet using Tomcat. My Tomcat works well (I tested it on dummy Hello World project). My parent directory is C:\Users\dolgopolov.a\Desktop\tattelecom\amsc\amsc . This is how I do: Run cmd.exe >cd C:\Users\dolgopolov.a\Desktop\tattelecom\amsc\amsc >jar -cvf tattelecom.war * Add tattelecom.war to C:\tomcat\tomcat7\webapps Run startup.bat This is what I've got: SEVERE: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component

HttpServletRequest - Quick way to encode url and hidden field paramaters

故事扮演 提交于 2019-12-25 01:52:51
问题 In my java app I'm preventing XSS attacks. I want to encode URL and hidden field paramaters in the HttpServletRequest objects I have a handle on. How would I go about doing this? 回答1: Don't do that. You're making it unnecessarily more complicated. Just escape it during display only. See my answer in your other topic: Java 5 HTML escaping To Prevent XSS 回答2: To properly display user-entered data on an HTML page, you simply need to ensure that any special HTML characters are properly encoded as

How to get request object in sessionDestroyed method?

北战南征 提交于 2019-12-25 01:51:12
问题 I am in need of Request object in sessionDestroyed method because I need to retrieve Cookies there. public void sessionDestroyed(HttpSessionEvent httpSessionEvent) { // Here I need to get Request object so that I can retrieve Cookies. } Is it possible to get request object so that I can retrieve Cookies there? 回答1: No. There is not necessarily means of a HTTP request when the session is been destroyed. It can namely be destroyed during a timeout because the client hasn't sent any request for

Spring MVC - Downloading PDF using outputstream & HttpServletResponse

非 Y 不嫁゛ 提交于 2019-12-25 01:49:48
问题 I'm trying to write a Controller that downloads a pdf file on the browser. I am using Jasper Reports to generate the pdf file in Java code (fully tested and it works perfectly). Now, I want to get the output stream that is being written by Jasper Reports and download it on the browser. However, when I click the button (which sends a POST to my mapped controller method), no download happens, and no error occurs. Relevant code : @RequestMapping("/vm/dormant/pdfReport") public void

the way to get a value from a hidden type correctly

泪湿孤枕 提交于 2019-12-25 01:49:37
问题 in a html table i construct in each row an edit button like the following: retour.append("<input type=\"hidden\" id=\"id_"+nomTab+"_"+compteur+"\" value=\""+object.getIdDailyTimeSheet()+"\" name=\"hd_"+compteur+"\" />"); this is the hidden type then i do the following: retour.append("<button id=edit name=edit type=button onClick= editarow()>"); retour.append("<img src=edit.gif />"); retour.append("</button>"); retour.append("</td>"); here i am using the hidden type to differentiate between my

Image is not displayed from Oracle table using servlet

与世无争的帅哥 提交于 2019-12-25 01:18:06
问题 After a long trial ,I finally successfully able to upload an image to an oracle database . At least my code says so. However to check whether the image has been successfully I wrote a servlet . After running the servlet I get a black screen in my browser and nothing else. The servlet code is: import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.sql.Blob; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement;

on Google App Engine 500 Error, it should be 200 instead of 500

六月ゝ 毕业季﹏ 提交于 2019-12-25 01:01:11
问题 requestToken = function() { var getTokenURI = '/gettoken?userid=' + userid; var httpRequest = makeRequest(getTokenURI, true); httpRequest.onreadystatechange = function() { if (httpRequest.readyState == 4) { if (httpRequest.status == 200) { openChannel(httpRequest.responseText); } else { alert('ERROR: AJAX request status = ' + httpRequest.status); } } } }; function makeRequest(url, async) { var httpRequest; if (window.XMLHttpRequest) { httpRequest = new XMLHttpRequest(); } else if (window

How to set date type values using Apache Commons BeanUtils,

梦想的初衷 提交于 2019-12-25 00:36:08
问题 I have an Html form with enctype="multipart/form-data" . I have an dto class it has all setter and getters . Since I am submitting form as multipart, getParameter() method will not work,to process html form fields I used Apache Commons BeanUtils. My servlet is as follow, List<FileItem> items = (List<FileItem>) new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request); for (FileItem item : items) { if (item.isFormField()) { // Process regular form field (input type="text|radio