Questions tagged [servlets]
Servlet is a Java application programming interface (API) running on the server machine which can intercept the requests made by the client and can generate/send a response accordingly.
servlets
33,020 questions
0
votes
1
answer
125
views
Implementing remember-me/stay logged in logic in a Servlet
I would like to implement a remember-me functionality in my very plain servlet-based system. No Spring, No Shiro, nothing. I'm mightily struggling to make it work.
On paper, it seems fairly ...
0
votes
0
answers
66
views
Jetty 12 cannot load ResourceServlet
I'm running a Java 21 web application with a static part under /webapp path. Until Jetty 11, we used the DefaultServlet for this....
0
votes
0
answers
70
views
Application migration to Websphere Liberty
I am migrating an application to Liberty. The application is servlet-based and uses JSP files. I have created Dockerfiles, a Helm chart, and Liberty configuration files such as ...
Advice
0
votes
1
replies
49
views
Share variable/object between multiple servlets
Suppose I want to create a simple counter app with three different servlets: one to read the value (GET), one to increment and one to decrement the value (both POST):
readvalue.java:
...
Advice
0
votes
8
replies
107
views
Image not displaying when running Java Servlet project on server (but works when opened directly in browser)
<img src="images/logo.png">
I created a web project using HTML and Servlets (no JSP).
When I open the HTML file directly using “Open in Browser,” the image displays correctly.
But when ...
0
votes
0
answers
63
views
Connecting Java backend(Servlets) to Vercel frontend(fetch API). Cors Error
So basically I have put up my backend on Render web Service (on tomcat) and my frontend(Nextjs) is on Vercel. I have put up a Filter for Cors Policy to intercept all policies and as well as handled ...
0
votes
1
answer
78
views
How to use slf4j-api > 2 in jersey servlet container
I have a Jersey servlet project, where I organize the depencies with maven. It runs in Tomcat.
Update of slf4j-api
Now I am trying to use ...
2
votes
0
answers
80
views
Zombie session after expiring cookies using Java Servlets
I have inherited some JAX-RS code with a logout function that appears to be properly "logging out" the user by redirecting to the login page, invalidating the session, and expiring the ...
1
vote
1
answer
99
views
How can I capture the full raw HTML content and also set header response value about that content with Servlet Filter
I want to be able to capture HTML content and then set a header about that content using servlet filter.
I Can capture the content but I always get an error that the response has already been ...
1
vote
1
answer
110
views
How to debug the Tomcat Catalina engine
When I tried doing research on this, everything I found was how to debug an application running under Tomcat. I'm trying to debug Tomcat itself, because something strange is happening that I can't ...
2
votes
1
answer
258
views
How can I upgrade code that uses Apache Commons FileUpload DiskFileItem for the Jakarta namespace?
I manage a Tomcat/JSP webapp. We are updating our source code to conform to the recent javax -> jakarta namespace change in ...
0
votes
0
answers
51
views
Spring Boot Global Exception Handler Returns 400, but Filter Still Returns 500 When Called by One Particular Caller
1. System Setup
Framework: Spring Boot REST API (servlet-based).
Global Exception Handler:
Uses @RestControllerAdvice to catch ...
0
votes
1
answer
143
views
dwr-2024 package throws internal version error
I have an older Java/JSP application that I have to update to Tomcat 10 by May 31, 2025. This change in Tomcat versions covers Java's recent javax -> jakarta ...
0
votes
1
answer
55
views
MongoDB Java Driver returns all documents instead of matching filter in Java Servlet
I'm building an Expense Tracker web app using Java Servlets and MongoDB. I want to filter expense documents based on user and ...
0
votes
1
answer
122
views
IllegalArgumentException ("getWriter() has already been called for this response") during response writing in AbstractJackson2HttpMessageConverter
Summary
We're seeing an intermittent IllegalArgumentException during HTTP response serialization using Spring Boot 3.4.2 on Kubernetes. The exact same image ...
0
votes
0
answers
110
views
Custom OncePerRequestFilter reads empty request body – why is the body already consumed?
I'm developing a Spring Boot application (with Spring Security) and need to add default headers (specifically, Content-Type and Content-Length) to requests targeting the endpoint /api/v1/mpos/set-...
0
votes
0
answers
72
views
Vaadin 23, Blank index.html page when routing any URL
I am trying to run a page using Vaadin 23, but I get index.html on any url
My project uses:
java version=17
spring-mvc version=5.3.20
apache tomcat version=8.5.85
But as a dependency manager on the ...
1
vote
1
answer
451
views
How to set up a Facelets template for a Jakarta Servlet web application (not a Jakarta Faces application)
This question was asked on Stack Overflow more than 12 years ago, and the answer was "No". Today, JSP is considered a deprecated technology, and Facelets has replaced it.
However, my ...
0
votes
1
answer
76
views
Session data is lost after submitting a form in servlet application
I'm working on a java servlet application on reset password function. The get method basically check a parameter email and check if the email valid. Then set the email as an attribute in the session. ...
1
vote
0
answers
60
views
Large file download using Servlet with Streaming without browser buffering
I am developing a Java 8 servlet to download a zipped resource. The file size can vary significantly, sometimes reaching up to 700MB. For testing, I am using a 350MB ZIP file.
The expected behavior is ...
0
votes
1
answer
47
views
jakarta.servlet.ServletException: Error instantiating servlet class [task_8newStart.EmployeeServlet] [duplicate]
I am a beginner when workign with servlets.
I am creating a servlet, but after running it, I am getting this error.
Can anyone help me to resolve this?
...
0
votes
1
answer
47
views
Tomcat cannot find jar in webapp's lib folder [duplicate]
Have a test servlet that connects to Mariadb jdbc connection.
It's not finding the jar file that's in the WEB-INF/lib folder - the jdbc driver.
If I save the jar file in catalina's lib folder, I get ...
0
votes
0
answers
121
views
java.lang.ClassNotFoundException: jakarta.servlet.SingleThreadModel
I am facing issue in my app, " Caused by: java.lang.ClassNotFoundException: jakarta.servlet.SingleThreadModel". I am aware that this class has been deprecated and removed from jakarta....
0
votes
2
answers
134
views
Should I use HttpServletRequest.getParameter() or HttpServletRequest.setAttribute() for passing data between components?
I would like to customize Access token based on authorization code which is sent in the token endpoint reqeust.
I am doing this as per spring boot Oauth2 documentation.Token customisation
Specifically,...
1
vote
1
answer
175
views
Check client connectivity to a RESTful Spring server without modifying application response
I have a REST service in Spring and an api that blocks for some before starting a heavy task and then returning it to the client. I want to check that the client is still connected to the socket of ...
0
votes
0
answers
57
views
Wildfly not loading annotated servlets from dependency jar
We are migrating a Java EE 8 project to Jakarta EE 10, from Wildfly 26 to Wildfly 34, but WF 34 stopped to load annotated Servlets from dependency jars.
Annotated Servlets (with ...
-3
votes
1
answer
427
views
Having trouble with JSTL libraries in my java JSP Servlet project [duplicate]
enter image description here
[enter image description here](https://i.sstatic.net/mLxE5RhD.png)
I am using Eclipse IDE.
it is a web dynamic project JSP Servlet and JSTL.
Eclipse version: 2024-12 (4.34....
0
votes
1
answer
130
views
Is it possible to externalize nested components
My current situation is that I have a maven project which I'm deploying to Tomcat as a .war file. Part of my project contents are actually third-party frontend ...
2
votes
0
answers
44
views
Websocket always closed using Tomcat 10.1
I'm working on a Servlet application using WebSocket with a Tomcat 10.1 server. My goal is to create a one-player (host) game via a WebSocket and allow other players to join this game in real time ...
1
vote
1
answer
57
views
0
votes
1
answer
286
views
How can I connect frontend (React) and backend developed by Java without using web application?
I am asked to create a e-commerce website for my school project. The frontend part will be developed using React. The backend part must be developed using Java where web application framework, e.g. ...
0
votes
1
answer
676
views
I got a java server online, on vercel, how to make request from it?
I have made a java server locally, it works perfectly with mysql db connection, i choosed to deployed it on vercel and make from it requests both from postman and also from the interface of the web ...
-2
votes
1
answer
259
views
java.lang.ClassNotFoundException: org.postgresql.Driver in HttpServlet [duplicate]
There is an error when I want to connect to a PostgreSQL database from a servlet connection, a ClassNotFoundException for the PostgreSQL driver, with some details about servlet.
...
0
votes
0
answers
27
views
How to make a data to be displayed whenever the JSP page is opened and not show empty data when data is actually present in the database? [duplicate]
I am trying to send partyList from AddPartyServlet.java to addParty.jsp. Whenever ...
1
vote
0
answers
47
views
How can I set my servlet as default mapping in Tomcat embedded?
I want to set my servlet as default handler at "/" in my Tomcat embedded project but it always return a 404 error on navigator. But if I set an index.html in webapp it can return and I can ...
-1
votes
1
answer
696
views
Does Tomcat 11 support Spring 6.1? [closed]
I know that Tomcat 11 supports servlet spec 6.1, but does it support olders as well?
Also, I'm not sure about the relationships between servlet specs and Spring versions. https://github.com/spring-...
0
votes
1
answer
72
views
When the session times out, a double click is required to go to the login page
I use this code. After setting passwordChanged, when I click (first request) then it invalidates the session in ...
-3
votes
1
answer
114
views
Why do I get the response code 200 when request sent from Postman to Tomcat server in my project. but get 404 in another project?
issue
Why do I get the response code 200 when request sent from Postman to Tomcat server in my project. but get 404 in another project?
To my project HealthHelper
...
0
votes
1
answer
101
views
Tomcat ignore metadata-complete="true" with servlet 6.1
My application does not use any servlet annotations. That I want skip the scanning for annotations. But it look like that Tomcat 11.0 ignore the ...
0
votes
2
answers
57
views
Why com.google.code.gson package can not convert value of java.sql.Timestamp correctly from a json string sent from Postman to Tomcat?
What I do?
I sent a GET request from Postman to Tomcat v9.0 with following data.
...
0
votes
1
answer
2k
views
Dependency 'jakarta.servlet:jakarta.servlet-api:10.0.0' not found [duplicate]
I was working on a maven project in intellij-idea and for some reason decided to change my java language level to 15 from 8 and now it does not recognise the jakarta package that I imported.
I tried ...
0
votes
0
answers
44
views
javax.servlet.Filter ClassNotFoundException OAuth2 [duplicate]
I'm trying to implement OAuth2.0 in my Spring Boot backend service, but I'm encountering the following error when adding my SecurityConfig class:
...
-1
votes
1
answer
58
views
How to add a "meta" element to the HTML in a response from a Servlet?
In Jakarta Servlet 6.1, how does one add a meta element to the response from a servlet?
For example, in HTML5 we can specify a character encoding like this:
...
0
votes
2
answers
659
views
Quarkus - problem accessing HttpServletRequest
I'm developing a Java application, using Quarkus 2.13.8.Final.
There is a simple endpoint, in which I'd use the HttpServletRequest instance:
...
0
votes
0
answers
35
views
0
votes
1
answer
265
views
How to Send a List of Objects with MultipartFile[] and Metadata in a Single Request in Spring Boot
The official documentation describes what to do if you need to get both json and multipart data from a request:
...
0
votes
1
answer
102
views
Springboot / HttpServletResponse is not retreiving the actual HTTP body
I am facing a weird issue on a Spring boot project where the body is not retrievable in the controller.
This is a bit specific: I am using a bc tls psk scheme to talk to sim cards and it has been ...
1
vote
1
answer
115
views
Java HTTP Servlet returns 405 despite implementing doPost [duplicate]
Here is the HTML code:
...
5
votes
1
answer
247
views
How to get client host/domain name in spring boot controller
I have a spring boot application with one rest api. Will deploy it in one linux server.
And we have multiple java applications deployed in multiple linux servers calls that api.
Whenever a request ...
0
votes
0
answers
16
views
Unable To Instantiate Servlet Class While Deploying WebApp through Tomcat using INTELLIJ IDEA [duplicate]
I was trying to make a servlet for webapp, In INTELLIJ IDEA. While deploying there was no error but when the servlet is called in the web, it says
"jakarta.servlet.ServletException: Error ...