Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package controller.servlets;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- public class PrimeiroServlet extends HttpServlet {
- /**
- * Handles the HTTP <code>GET</code> method.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- //processRequest(request, response);
- }
- /**
- * Handles the HTTP <code>POST</code> method.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
- resp.setContentType("text/html");
- PrintWriter out = resp.getWriter();
- out.print("Os dados digitados são: <BR><BR>");
- out.print("Nome: <b>" + req.getParameter("nome") + "</b><BR>");
- out.print("Idade: " + req.getParameter("idade") + "<BR>");
- out.print("Cidade: " + req.getParameter("cidade") + "<BR>");
- out.print("Estado: " + req.getParameter("estado") + "<BR><BR>");
- out.print("Muito obrigado!!!");
- }
- /**
- * Returns a short description of the servlet.
- *
- * @return a String containing servlet description
- */
- @Override
- public String getServletInfo() {
- return "Short description";
- }// </editor-fold>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement