Unit Test cases [Junit] not possible in raw java servlets [closed]
I had a Java servlet webapp and I had to write junit test cases for that.But Unit test won't work cause the mocked methods were not being used.
View ArticleHow Can i get the productId from the JS function?
<% int productId=? ProductsDao pd = new ProductsDao(ConnectionProvider.getConnection()); Products p=pd.getProductByPid(productId);%> function attachEditEventListeners() { const editButtons =...
View ArticleServlet and Google Gemini connection error
HTTP Status 500 - Internal Server Error type Exception reportmessage Internal Server Errordescription The server encountered an internal error that prevented itfrom fulfilling this...
View Articlejava.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet netbeans in...
I'm developing a servlet that get a some detail from index.jsp form when i submit servlet throws following exception. I'm using NetBeans and Apache Tomcat/10.0.16.HTTP Status 500 – Internal Server...
View ArticleCannot connect the database
I have tried to insert the data that user inputted by using the servlet. I am following a video, but I have an error in my code.In the video, when the user has input the data, it will display a succuss...
View ArticleConnection Problem between Database (maybe) [closed]
I have tried to insert the data that user inputted by using the servlet. I am following a video, but I have an error in my code.In the video, when the user has input the data, it will display a succuss...
View ArticleHow to parse Json received in a http response [duplicate]
I'm doing a simple project where i need to take the user Input from a Jsp and show it in another jsp,i did send data from the first jsp using javascript but how do i parse it again with java ? In my...
View ArticleAccess @Context UriInfo from a HttpServlet [duplicate]
I need to acess the UriInfo from my HttpServlet, but whenever I try to inject it, the object is null.Is there a way to access it from a HttpServlet? Am I missing something?I'm already injecting Spring...
View ArticleServelt -> postman -> Google Gemini
The error:HTTP Status 405 - HTTP method GET is not supported by this URLtype Status reportmessage HTTP method GET is not supported by this URLdescription The specified HTTP method is not allowed for...
View ArticleTomcat does not create a new request instance on every client request
I learned when a request comes in from a client, the Tomcat generates a new request instance for each request.So I print out HttpServletRequest's hashcode but it was always sameHere is my code,package...
View ArticleHow does Spring container give reference to interface or class type we pass...
I have been studying spring and spring mvc framework, and I am curious to know that how the spring container gives us the reference to whatever Interface or Class type we pass as an argument to our...
View ArticleCorrect syntax for a servlet that doesn't "return anything"?
What is the correct way of terminating a servlet that doesn't return any data to the client?The purpose of the servlet in question is to recive some data from an Ajax request and fire off a TCP message...
View ArticleSharing session data between contexts in Tomcat
I have been looking at solutions for sharing session data between mutliple war files. I came across the following solution http://www.fwd.at/tomcat/sharing-session-data-howto.htmlThe basic idea of it...
View ArticleHow do I create a new Servlet class in IntelliJ
Summary: The Create new servlet doesn't show up in the File > New > ... menu and I'm convinced this did work in older versions of InteliJ.I'm using InteliJ 2024.1.1 Utlimate.I've created a maven...
View ArticleJava Servlet does not recognize my route/class
I am running a Java servlet using JDK 17, Tomcat 9.0 and Maven on VSCode. I am facing the problem that, when I create a new class to use a new route, Tomcat returns me an Error 404 saying that "The...
View ArticleGoogle app engine: call from another domain not working
calling an app engine (jetty @WebServlet) from another domain gives an error. In the logs I see the 'preflight' successful result, but the servlet code is not reached (a printout as the first line does...
View ArticleHow to evaluate EL expression in Tomcat servlet environment?
How to evaluate EL expression in Tomcat servlet?Tomcat uses Jasper...
View ArticleEclipse complains about "jakarta.servlet.http.HttpServlet" was not found
I am picking up an old project which has a lot of old dependencies.I am using "Eclipse IDE for Enterprise Java and Web Developers".After importing the source to Eclipse, Eclipse is complaining all my...
View ArticleCQ5 SlingServlet and resourceTypes not working for specific resource paths
If I define a Sling Servlet as follows:@SlingServlet( label="TestResourceTypeServlet", name = "com.company.project.servlets.TestResourceType", extensions = {"bob"}, resourceTypes= {"cq:Page"}, methods=...
View ArticleWhat is the behaviour of getParameter for post and get actions?
I have a java servlet with a URL Query string with instructions like thishttp://hostname/servet?param1=value1¶m2=value2I also structure the doPost/doGet like thispublic void...
View Article