reset password
Author Message
Vanquish39
Posts: 134
Posted 01:02 May 03, 2011 |

In the lab it said, "In the doPost() method, perform the search, store the results in a List<Car>, and pass it as a request scope variable to a JSP to display."


How does one pass it by "request scope"  from a servlet to jsp? 

Does it mean request.setAttribute("foundCars", list) and forward that by request.getDispatcher().forward(request,response)?

dely
Posts: 32
Posted 01:06 May 03, 2011 |

yes

abess
Posts: 26
Posted 01:15 May 03, 2011 |

yep

Vanquish39
Posts: 134
Posted 01:26 May 03, 2011 |

Thanks guys for quick reply, btw, just outta curiosity because I haven't tried it yet, can we do request.getDispatcher... from the doPost() method instaed of doGet()?

Last edited by Vanquish39 at 01:27 May 03, 2011.
abess
Posts: 26
Posted 01:26 May 03, 2011 |

yupp

Vanquish39
Posts: 134
Posted 01:28 May 03, 2011 |

lol

Vanquish39
Posts: 134
Posted 01:29 May 03, 2011 |

just again outta curiosity, if we're using mvc then we hardly ever use <jsp:useBean> expressions right?

dely
Posts: 32
Posted 01:30 May 03, 2011 |

yea I never used it in my hw, it was all expression languages form e

abess
Posts: 26
Posted 02:01 May 03, 2011 |

yeah, I haven't used it either... only get/set Attributes

cysun
Posts: 2935
Posted 07:36 May 03, 2011 |
Vanquish39 wrote:

just again outta curiosity, if we're using mvc then we hardly ever use <jsp:useBean> expressions right?

In fact you should never use <jsp:useBean> in MVC. <jsp:useBean> creates a bean by a JSP, which is Model 1. In MVC, model objects (i.e. beans) should be created by servlets (i.e. controllers), not JSP (i.e. views).