servlets

HTTP Status 404 - /liangweb/TimeForm

巧了我就是萌 提交于 2020-01-17 13:49:12
问题 i have just started working with tomcat and servlet. after running some html page i was trying to run this timeform.it's giving me page.but when i click on submit page it give me this error instead of time.please help me. import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import java.text.*; public class TimeForm extends HttpServlet { private static final String CONTENT_TYPE = "text/html"; private Locale[] allLocale = Locale.getAvailableLocales();

request.getContentLength() return 0 when file size is greater than 2gb

我与影子孤独终老i 提交于 2020-01-17 13:43:29
问题 Using a file upload in my project as : <s:form id="uploadData" action="UploadAction" namespace="xyz" validateFields="false" method="post" enctype="multipart/form-data"> But the request.getContentLength() method returns correct value for less than 2 gb and 0 for anything above it. The probable reason being datatype of the content-length as int. Is there any other way where the request parameter: content-length can be converted into long type in order to support uploads greater than 2gb. please

i want to retrieve password from database but when program run result be null i don not know why?

拟墨画扇 提交于 2020-01-17 12:15:06
问题 //dopost methode @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String password = null; response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String parm; parm=request.getParameter("user_name"); String User_name=parm; parm=request.getParameter("National"); int National_ID=Integer.parseInt(parm); try{ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); con

i want to retrieve password from database but when program run result be null i don not know why?

淺唱寂寞╮ 提交于 2020-01-17 12:12:24
问题 //dopost methode @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String password = null; response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String parm; parm=request.getParameter("user_name"); String User_name=parm; parm=request.getParameter("National"); int National_ID=Integer.parseInt(parm); try{ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); con

ClassNotFoundException (inner class) when I run my servlet from Tomcat

偶尔善良 提交于 2020-01-17 07:51:42
问题 I tried to deploy the servlets. I have a inner class, but it seems like the complier cannot find the inner class. It generates the java.lang.ClassNotFoundException exception. Below is my servlets java code, web.xml, error message. Hope someone could help me. Thank you in advance. Servlet java code package com.tutorials; import java.awt.BorderLayout; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.io

ClassCastError when share objects between webapp

萝らか妹 提交于 2020-01-17 07:05:08
问题 Note: this is not cross-posting (although it's related to my other question shared objects between webapps of the same tomcat) I have 2 webapps running at two contexts: c1, c2 (both immediately after the root). I put a startupListener in c1 to share a variable, and another one in c2 to retrieve it. The problem is if I share an object of built-in datatypes (like HashMap, Integer,...) it is ok, but custom datatype can't be cast. For example, if I have a custom class named User, and pass an

jQuery $.post sending image file to servlet

谁都会走 提交于 2020-01-17 05:37:11
问题 I have javaee project. I want to send image file to my servlet via ajax. Ajax not sending image file to my java class. But it is sending textarea value. Here is my form <form enctype="multipart/form-data" beanclass="ActionBean"> <input type="file" id="uploadFile" name="newAttachment"/> <textarea name="name" id="name" rows="2" cols="30"></textarea> <s:submit value="Edit" name="saveOfferInfo" onclick="return edit(this);" /> JavaScript function: function edit(button) { var form = button.form;

Spring can't compile jsp with javax.servlet

偶尔善良 提交于 2020-01-17 04:55:30
问题 I have a spring project and everything worked fine. My gradle dependencies compile has the following compile 'org.springframework:spring-core:4.1.2.RELEASE', 'org.springframework:spring-web:4.1.2.RELEASE', 'org.springframework:spring-webmvc:4.1.2.RELEASE', 'org.springframework:spring-orm:4.1.2.RELEASE', 'org.springframework:spring-context:4.1.2.RELEASE', 'org.springframework:spring-tx:4.1.2.RELEASE', 'commons-dbcp:commons-dbcp:1.4', 'mysql:mysql-connector-java:5.1.6', 'org.hibernate:hibernate

Java: Which Apache Digester Class?

北战南征 提交于 2020-01-17 03:14:30
问题 I'm supporting a web application / Java servlet that has been failing to start. The issue turns out to be a relatively straight-forward java.lang.NoClassDefFoundError exception, thrown by org.apache.webapp.balancer.RulesParser . The filter class that throws the exception expects the Digester class to exist in the package: org/apache/tomcat/util/digester That package doesn't appear to exist in the application lib, but there is an instance of the class in: org/apache/commons/digester Which is

in jsp, get realPath of deployed project

我与影子孤独终老i 提交于 2020-01-17 02:41:32
问题 in servlet, as we can access the real path of deployed project ServletContext context = getServletConfig().getServletContext(); string contextStr = context.getRealPath("....."); How can i access the deployed project path in JSP page, any idea please ? 回答1: <%=request.getRealPath("write_your_file_name")%> 回答2: It should work just the same, for example by accessing ${pageContext.servletContext.getRealPath("...")} to get the same results. JSP are nothing more than servlets after they got