There is such a code:
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); String nameDB = req.getParameter("nameDB"); String nameTable = req.getParameter("nameTable"); String rezult = getCr(nameDB, nameTable); //получаю строку из бд. req.setAttribute("textA", rezult); RequestDispatcher dispatcher = req.getRequestDispatcher("/post.jsp"); dispatcher.forward(req, resp); } @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); RequestDispatcher dispatcher = req.getRequestDispatcher("/index.jsp"); dispatcher.forward(req, resp); }
and there are two files:
index.jsp - in which the form with fields and sending a post-request
form id="getCreate" action="post.jsp" method="post"/form input name="nameDB" form="getCreate" input name="nameTable" form="getCreate" input type="submit" form="getCreate"
post.jsp - with the
${textA}
field, you need to output the result there.
War file on Tomcat - I run - I enter the data and ... an empty window opens. What am I doing wrong? How do I send data from this form to a java-application so that there is a connection to the database and the data I need is pulled out?