Should use req.setAttribute() or res.setAttribute() ?
Post by:Ian Yang
If "MyJsp1.jsp" is redirected to "MyServlevt.java" by clicking "Action=...", and then in "MyServlevt.java" I want to pass an object from this servlet to another jsp page "MyJsp2.jsp" by using "forward(req, res)", then should I use "req.setAttribute()" or "res.setAttribute()" in "MyServlet.java" servlet to send the obj to "MyJsp2.jsp" ? thanks.
Post by:james edwin
Hi, There are three ways..to pass object from servlet to JSP. 01) set in application level. - avaiable to whole application.(in this u can always set Database connection object or something else which your application is sharing)
02) set in session - for each client session will be different. 03) Set in request- request.setAttribute("",...) Its all depend on your problem secnario..pls see which one fits in your problem. Take care
This thread has been viewed 1030 times.
All times above are in ranch (not your local) time.
The current ranch time is Dec 16, 2018 06:02:06.