简体   繁体   中英

Getting response from servlet. ExtJs

I have a extJs form with fileupload and servlet. After uploading file i want to get response from servlet.

i do this System.out.println("{success:true, error:'error'}"); But in firebug in POST i dont see anything. This code works in case wiht jsp but not servlet. So how to send parametrs from servlet?

System.out PrintStream is not the the output stream of your servlet response. It is still the "standard" system out stream. Most application servers redirect that to a log file.

Servlet's service() method, as well as do*() methods of HttpServlet, take ServletResponse respectively HttpServletResponse as a parameter. When implementing a servlet, one can call getWriter() on that parameter to get a PrintWriter open on response's output stream. That can be used to print something to the response.

So, your code should be something like:

response.getWriter().println("{success:true, error:'error'}");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM