How to handle more than one responses?

42 views Asked by At
public class Uploadservlet extends HttpServlet
{
    
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws IOException, ServletException
    {
        String name="arul";
        PrintWriter out=res.getWriter();
    if(name=="arul")
        {
        
        
            req.getRequestDispatcher("uploadfile.jsp").forward(req,res);
            
                out.println("<h3>hello world</h3>");
            
            System.out.println("hello world");
            System.out.println("hi");       }
        else
        {
           out.println("hi hello");
           System.out.println("hi hello");
        
        }
    }}
    

After forwarding the request through request dispatcher, what will happen to the below code? My out.println is not working but System.out.println after that is working, what happened to the printwriter

0

There are 0 answers