Labs
A servlet in this lab uses a StockProvider object that queries a database. We need to load the database it uses.
JSPViews/DBSETUP.txt
- Follow the instructions in this file to load the
stockdbdatabase.
Now we will change a servlet to display different JSP's depending on what it finds in the database.
- Create a new JSP page
/WEB-INF/views/error.jsp. - Add the text
Invalid Stock requested. - Add a link to
selectJSP.htmlto return to the search. - Style the page however you wish.
(Solution: WEB-INF/solutions/views/error.jsp)
- In
StockServletJSP, if the requested stock does not exist, select your error page as the view. Otherwise, continue to select/WEB-INF/select.jsp.
(Solution: StockServletJSPError.java)