I am trying to run a character length check first and if user pass that than want to call the servlet which will return that user logged in. After running the above jsp code it is checking the password length and Rno check correctly but not running the servlet after that given below. I want to do this in doPost
Tag: servlets
Struts pdf view showing null pointer exception in response object
I have created a pdf with iTextpdf but while setting the response.setContentType(“application/pdf”); getting null pointer exception From jsp struts.xml action class Answer Since it was from the same page intializing the response, reset and closing worked for me
Java servlet request working correctly only for first of multiple auto generated html elements
unfortunately this is a project for school and most of the variables are in my native language, i’ll translate any if needed, but leave the code as is, just in case that’s somehow the problem. I’m making a web app for a Catering Service, using Java servlets for my backend and JSP for my front end. The session stores an
Variable returns null
In my project ,I need to pass the “price” value which is retrieved from the database in “Availability.java” to “display.jsp”.I have achieved it, but the problem is…. I also need to pass the “price” value from “display.jsp” to “seat.jsp”. When I tried, it returns null value for the price variable. Availability.java display.jsp seat.jsp How can I achieve this? Kindly answer
java.lang.IllegalStateException: ServletConfig has not been initialized in Tests
Here is my Servlet. It gets a String that I’ve put in a ServletContext in my Listener. Here is the Test class The exception I have Code from GenericServlet (javax package) where the exception happens But how do I pass ServletConfig to Generic Servlet or Initialize it? Answer Create a mock ServletConfig, mock its getServletContext() method to return your mocked
Should I use ThreadLocal to store connections?
I code my Test project and it is prohibited to use Spring and Hibernate there. I wanted to manage my transactions from Service layer. For this I have created a class that gets a Connection from the pool and puts it in the ThreadLocal. This is an example of the fields and the method. The class has also close, rollback
Why my REST api created with camel servlet doesn’t expose?
I’m currently struggling with exposing the REST api in my project using Apache Camel. When I run the project it seems to be fine in the console, but it just doesn’t work: curl http://127.0.0.1:8080/materials curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused Here’s the pom.xml file: Here’s the code I wrote: I’m not sure to put the
Log4j2 tomcat 10 memory leaks on shutdown
I have memory leaks at my tomcat 10.0.16 servlet application. I am using Log4j2 2.17.2 version, and after tomcat shutdown I see next logs: My pom.xml for Log4j2 is: And also log4j2 config Most common fix is to add log4j-jakarta-web, but this does not works for me Answer Fully deleting target folder and recompiling my project seems like resolved my
Java ClassVersionError although version seems to be okay
I’m getting the following error in my java web app (The application launches okay but when I click a button following error occurs). I’m using Tomcat (7.0.109) to run this application. java.lang.UnsupportedClassVersionError: FileDetailsServlet has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions
Session created by Tomcat
I am learning session with servlets and i read in the book that to create a session we need to call as below. HttpSession session = request.getSession() This causes the web container to create a session ID and send it back to client so that client can attach it with every subsequent request to the server. When i open developer