import java.io.File; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class dibujo_carta */ @WebServlet("/dibujo_carta") public class dibujo_carta extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public dibujo_carta() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter escribirPagina = response.getWriter(); try { String palo = request.getParameter("P0"); int valor = Integer.parseInt(request.getParameter("P1")); palo = palo.toUpperCase(); if(palo.compareTo("S")==0 || palo.compareTo("H")==0 || palo.compareTo("C")==0 || palo.compareTo("D")==0) { if(valor>=1 && valor<=13) { escribirPagina.append( "\n" + "\n" + "\n" + "\n" + "Agenda\n" + "\n" + "\n" + "

Tu carta es:

\n" + " \"Resultado

\n" + " Volver al selector de carta

" + " Volver al menu principal" + "\n" + "" ); }else { escribirPagina.append( "\n" + "\n" + "\n" + "\n" + "Agenda\n" + "\n" + "\n" + "

El campo valor solo admite valores entre entre el 1 y el 13



\n" + " Volver al selector de carta

\n" + " Volver al menu principal" + "\n" + "" ); } }else { escribirPagina.append( "\n" + "\n" + "\n" + "\n" + "Agenda\n" + "\n" + "\n" + "

El campo del palo solo admite valores:
* S
* H
* C
* D



\n" + " Volver al selector de carta

\n" + " Volver al menu principal" + "\n" + "" ); } }catch(NumberFormatException e){ escribirPagina.append( "\n" + "\n" + "\n" + "\n" + "Agenda\n" + "\n" + "\n" + "

El campo del valor solo admite numeros enteros



\n" + " Volver al selector de carta

" + " Volver al menu principal" + "\n" + "" ); } } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }