Skip to content
Advertisement

Tag: servlets

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

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

javax.ws.rs.Path how to intercept just the project root without compromising all the other paths

I have this web.xml, don’t want a suffix for the url-pattern so I’m using a /* pattern: This is my RestVersion.java class that I want to manage the root requests: Where IRestVersion.java is the following: The problem is that any other path is intercepted by this RestVersion class, like this: http://localhost:8080/ —> it answers correctly with the RestVersion.version() json http://localhost:8080/asd

Does GlassFish servlet container use that catalina?

I am running the same servlet application in both Apache Tomcat and GlassFish servers. I wanted to see the ServletConfig and ServletContext implementation class names. Surprisingly, I found that GlassFish is also using from Apache Tomcat’s catalina classes. Is my observation correct? If yes, why isn’t GlassFish using its own servlet implementation classes? [ Answer According to this FAQ entry

Wildfly Undertow: jakarta.servlets.Servlet does not implement javax.servlet.Servlet

I am trying to migrate some Servlets from javax libraries to jakarta. Changes are pretty straightforward but, when I try to run them on Wildfly 23, I get this error message: Servlet JAX-WS-Service of type class com.sun.xml.ws.transport.http.servlet.WSServlet does not implement javax.servlet.Servlet This happens for this servlet (used for JAXWS, but that’s not the point) but also with my own servlets,

Is there any other way to convert string value into integer value in jsp? I am trying a basic program in jsp

index.html Getting an exception in op.jsp named java.lang.NumberFormatException HTTP Status 500-Internal Server Error op.jsp While converting value from string to integer it is generating an exception Also Tried below code but still not working Answer The problem is not with your code, but rather how you run it. You need to access index.html first to allow you to input numbers,

Advertisement