Our application currently using 3 different servlet mapping syntax, wondering if there's a benefit to setting them all up one way aside from personal preference on the syntax of the routing.
1. <servlet> and <servlet-mapping> tags in web.xml pointing to Java class which extends HttpServlet, all requests go into service() method. This is built into JDK?
2. @WebServlet annotation on class, routes requests into doGet() or doPost() methods, requires javax.servlet-api dependency.
3. @RestController, @RequestMapping/@GetMapping/@PostMapping annotation, routes requests directly into individual methods, requires spring-framework dependency and apparently custom initializer class setup.
I believe that as usual consistency is more important than what is
chosen.
I would:
* use the Spring annotations for Spring web services as that is the
standard for those
* decide on either web.xml or @WebServlet for anything not Spring web service
Arne
I believe that as usual consistency is more important than what is
chosen.
I would:
* use the Spring annotations for Spring web services as that is the
standard for those
* decide on either web.xml or @WebServlet for anything not Spring web
service
Consistency is the first issue, as I pulled together decades of old
code into one clean maven project with many modules. Some modules
create wars, some create jars. Two of the war modules have spring
framework config files. I'm wondering if we'll see benefits in
setting all modules up for Spring, as we're modifying literally all
the code anyway doing linting and unit tests, or if it makes any
sense to use all Spring controllers in 2 modules and clean the rest
up with a different style. There's literally one class using the servlet-mapping servlet, I don't see any upside to that syntax, the
rest that aren't Spring are using WebServlet. All I know is the
different syntax, I'm not aware of functional or performance benefits
of any style choice.
If you only have one servlet using web.xml then I would change that
to annotation. There should not be any runtime performance difference
after startup. I don't remember if the annotations support all the functionality in web.xml, but if the annotation support the
functionality you need then you are good.
Regarding cleanup - are you planning to stay on servers
(Tomcat or JBoss or whatever) or are you planning on moving
entirely to SpringBoot or are you planning to do both?
That may influence the road forward a lot.
Arne
Regarding cleanup - are you planning to stay on servers (Tomcat or
JBoss or whatever) or are you planning on moving entirely to
SpringBoot or are you planning to do both? That may influence the
road forward a lot.
Arne
Yeah I looked at spring boot, seems like that's for using spring as
the web server. We are running on tomcat, planning to move to AWS
which I believe also runs it on tomcat (in a docker container?). We
have a local test configuration of tomcat in eclipse, someone else
handles setting up the servers.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 58:31:11 |
Calls: | 6,712 |
Files: | 12,243 |
Messages: | 5,355,631 |