servlets

Servlet to jsp communication best practice

徘徊边缘 提交于 2020-01-24 06:45:17
问题 I'm learning how to write java servlets and jsp pages on google app engine. I'm attempting to use an MVC model but I'm not sure if I'm doing it right. Currently, I have a servlet that is called when a page is accessed. The servlet does all the processing and creates a HomePageViewModel object that is forwarded to the jsp like this: // Do processing here // ... HomePageViewModel viewModel = new HomePageViewModel(); req.setAttribute("viewModel", viewModel); //Servlet JSP communication

How to check whether the tomcat server is listening on particular port? [duplicate]

让人想犯罪 __ 提交于 2020-01-24 01:59:06
问题 This question already has answers here : Tomcat in Idea. war exploded: Server is not connected. Deploy is not available (13 answers) Closed 4 years ago . I'm trying to run a servlet program with tomcat as server. But the tomcat server is not running. I looked at the services.msc but it's not there. Below is the log created while running the servlet program via intelj "E:\Avinash\Avinash\Inteljidea projects\apache-tomcat-8.0.23\bin\catalina.bat" run [2015-06-12 11:15:57,837] Artifact servlet

What is the difference between a Servlet filter and a Jersey filter?

江枫思渺然 提交于 2020-01-23 18:05:15
问题 I read a lot of tutorials but I don't understand what are the differences between Servlet filters and Jersey filters. Anyone can exmplain me? 回答1: In Servlet container, you have Servlets and you have Servlet Filters. Generally, the Servlets handle processing of the request, and the Servlet Filter handles pre an post processing of the request. So a request flow looks like Request --> Filter --> Servlet --> Filter --> Response The Jersey application, it is implemented as a Servlet 1 . So in the

What is the difference between a Servlet filter and a Jersey filter?

怎甘沉沦 提交于 2020-01-23 18:02:59
问题 I read a lot of tutorials but I don't understand what are the differences between Servlet filters and Jersey filters. Anyone can exmplain me? 回答1: In Servlet container, you have Servlets and you have Servlet Filters. Generally, the Servlets handle processing of the request, and the Servlet Filter handles pre an post processing of the request. So a request flow looks like Request --> Filter --> Servlet --> Filter --> Response The Jersey application, it is implemented as a Servlet 1 . So in the

How to do file I/O with a servlet running on Tomcat

泪湿孤枕 提交于 2020-01-23 07:32:52
问题 I am writing a Java servlet, using Tomcat as the container, which creates and serves PDF files to the end-user. Currently the PDF files are created in-memory and written out as a response to a POST. I would like to change this up somewhat so that the PDF files are written to disk (so they can be served up again later). I am having trouble locating a suitable "how-to" for doing this. How can I configure my servlet to write to and read files from a directory server-side? From what I've read, I

How to do file I/O with a servlet running on Tomcat

China☆狼群 提交于 2020-01-23 07:32:13
问题 I am writing a Java servlet, using Tomcat as the container, which creates and serves PDF files to the end-user. Currently the PDF files are created in-memory and written out as a response to a POST. I would like to change this up somewhat so that the PDF files are written to disk (so they can be served up again later). I am having trouble locating a suitable "how-to" for doing this. How can I configure my servlet to write to and read files from a directory server-side? From what I've read, I

Sending data via request header vs sending data via request body

北慕城南 提交于 2020-01-23 04:34:07
问题 What is the difference between sending data through the request header and sending data through the request body. Under what circumstances, we have to send the data through the header/body and when shouldn't we send the data through header/body ? 回答1: It is usually a good idea to use the headers for metadata and the body for the data that is used by the business logic. Some points to consider: 1) If the data is sent via HTTP instead of HTTPS, the proxy servers can modify the headers. 2) If

Failing to @AutoWire a member in a @WebServlet

回眸只為那壹抹淺笑 提交于 2020-01-23 02:01:45
问题 I can't seem to get my servlet's fields to @AutoWire; they end up null. I have a pure annotation-configured webapp (no XML files). My servlet looks like this: @WebServlet("/service") public class SatDBHessianServlet extends HttpServlet { @Autowired protected NewsItemDAO mNewsItemDAO; } Other @AutoWired things seem to work fine, both @Service objects and @Repository objects. But not this one, and I can't figure out why. I even tried adding its package to the ComponentScan(basePackages) list

Adding multiple servlets in single web.xml

谁都会走 提交于 2020-01-22 19:45:10
问题 I am trying to run two Servlet-class in a single web.xml but its not working, each servlet-class works fine independently. web.xml : <servlet> <servlet-name>spring-ws</servlet-name> <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class> <init-param> <param-name>transformWsdlLocations</param-name> <param-value>true</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring-ws</servlet-name> <url

What is 'service' method in HttpServlet class?

拟墨画扇 提交于 2020-01-22 06:00:25
问题 Below is a simple servlet written for learning. package com.example.tutorial; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class ServletExample extends HttpServlet { private static final long serialVersionUID = 1L; protected void service(HttpServletRequest request, HttpServletResponse response) throws