servlets

JSP Servlet session invalidate() does not make session null

大兔子大兔子 提交于 2020-01-03 18:46:45
问题 I have three simple HttpServlet classes in my JSP project, "LoginServlet", "LogoutServlet" and "ProfileServlet". LoginServlet: log in user by setting "name" attribute to session LogoutServlet: log out user and invalidate session ProfileServlet: display user welcome info if user has logged in The last two servlets are as below that I reckon are problematic. @SuppressWarnings("serial") public class LogoutServlet extends HttpServlet { protected void doGet(HttpServletRequest request,

JSP Servlet session invalidate() does not make session null

痴心易碎 提交于 2020-01-03 18:46:33
问题 I have three simple HttpServlet classes in my JSP project, "LoginServlet", "LogoutServlet" and "ProfileServlet". LoginServlet: log in user by setting "name" attribute to session LogoutServlet: log out user and invalidate session ProfileServlet: display user welcome info if user has logged in The last two servlets are as below that I reckon are problematic. @SuppressWarnings("serial") public class LogoutServlet extends HttpServlet { protected void doGet(HttpServletRequest request,

Tomcat7 HTTP Status 500 - Servlet execution threw an exception

依然范特西╮ 提交于 2020-01-03 17:27:39
问题 type Exception report message Servlet execution threw an exception description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: Servlet execution threw an exception root cause java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClassCond(Unknown Source) java.lang.ClassLoader.defineClass(Unknown

Tomcat7 HTTP Status 500 - Servlet execution threw an exception

丶灬走出姿态 提交于 2020-01-03 17:27:10
问题 type Exception report message Servlet execution threw an exception description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: Servlet execution threw an exception root cause java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClassCond(Unknown Source) java.lang.ClassLoader.defineClass(Unknown

Can I use servlet api 3.0 and jetty 8?

只谈情不闲聊 提交于 2020-01-03 16:54:58
问题 I want to use 3.0 servlet-api with Jetty 8. Currently 2.4 servlet-api is defined in my web.xml. And in the webdefault.xml 2.5 servlet-api is defined. Someone else set this up so they very well might have done something wrong. Which servlet-api version am I actually using? 2.4 or 2.5? I have 3.0 already in my classpath. What do I need to change in web.xml and/or webdefault.xml to get it working? Thank you in advance. 回答1: You normally don't provide the Servlet API yourself. This is normally to

How to get a welcome page from Tomcat root, rather than webapp context?

强颜欢笑 提交于 2020-01-03 14:02:22
问题 In Tomcat 7, I want my welcome page (index.html) to load when I access localhost:8080/. Right now, I have to go to the webapp context, localhost:8080/MyWebApp. Is there a folder in Tomcat to place pages that are not part of a webapp? I'm confused how this works... EDIT: I notice that the web.xml for the Server in Eclipse has a servlet called "default" which is mapped to "/"... I wonder if I have to change something here? EDIT2: I found this: http://wiki.apache.org/tomcat/HowTo#How_do_I

How to get a welcome page from Tomcat root, rather than webapp context?

自闭症网瘾萝莉.ら 提交于 2020-01-03 14:01:29
问题 In Tomcat 7, I want my welcome page (index.html) to load when I access localhost:8080/. Right now, I have to go to the webapp context, localhost:8080/MyWebApp. Is there a folder in Tomcat to place pages that are not part of a webapp? I'm confused how this works... EDIT: I notice that the web.xml for the Server in Eclipse has a servlet called "default" which is mapped to "/"... I wonder if I have to change something here? EDIT2: I found this: http://wiki.apache.org/tomcat/HowTo#How_do_I

shared objects between webapps of the same tomcat

此生再无相见时 提交于 2020-01-03 13:36:46
问题 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. My startuplistener in c1 is: public void contextInitialized(ServletContextEvent sce) { HashMap <String,Object> database ; //some code to init database ServletContext context = sce.getServletContext().getContext("/c1"); if (context!=null) { context.setAttribute("crossContext", true); context.setAttribute("cache", database);

Brackets in a Request URL are legal but not in a URI (Java)?

元气小坏坏 提交于 2020-01-03 11:00:10
问题 Apparently brackets are not allowed in URI paths. I'm not sure if this is a Tomcat problem but I'm getting request with paths that contains ] . In otherwords request.getRequestURL() == "http://localhost:8080/a]b" request.getRequestURI() == "/a]b" BTW getRequestURL() and URI are generally escaped ie for http://localhost:8080/a b request.getRequestURL() == "http://localhost:8080/a%20b" So if you try to do: new URI("http://localhost:8080/a]b") new URI(request.getRequestURL()) It will fail with a

writing a poi workbook to output stream is generating weird values

无人久伴 提交于 2020-01-03 10:04:45
问题 i am aiming to create an Excel file for the user to download via apache poi. I have this code in my servlet: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // create a workbook , worksheet Workbook wb = new HSSFWorkbook(); Sheet sheet = wb.createSheet("MySheet"); CreationHelper createHelper = wb.getCreationHelper(); // Create a row and put some cells in it. Rows are 0 based. Row row = sheet.createRow((short)0); Cell cell =