How to call Servlet from another Servlet? both in one app.
public class DBaddData extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
....some actions here...
...get data from JSP...
...call INSERT INTO method...
...and then I want to call SELECT servlet...
RequestDispatcher view = getServletContext().getRequestDispatcher("/myServlets/DBselTankList");
view.forward(req, resp);
}
}
But I got only:
The requested resource is not available.
"Select servlet" calls select method from DB and then show JSP with results
public class DBselTankList extends HttpServlet {
protected void processRequest(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
DBSelectRows dbSR = new DBSelectRows();
List<DBObjBaseStd> dboBStd=new ArrayList<DBObjBaseStd>();
dboBStd=dbSR.sel(DBConnStrings.driver, DBConnStrings.url, DBConnStrings.dbName, DBConnStrings.userName, DBConnStrings.password, DBConnStrings.sslState);
req.setAttribute("list", dboBStd);
RequestDispatcher view = req.getRequestDispatcher("selectedTankList.jsp");
view.forward(req, resp);
}
}
I also want to get this selectedTankList.jsp by link from header
<a href="selectedTankList.jsp">Tank list</a>
But how to call "Select servlet" without form and submit button?