Commit f743abbb by Matias Ferreira

quitando archivos de prueba

parent 50399e39
package com.roshka.webprojecttest.servlets;
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;
@WebServlet("/suma")
public class SumaRequestServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
PrintWriter pw = new PrintWriter(resp.getOutputStream());
String s1 = req.getParameter("s1");
String s2 = req.getParameter("s2");
if(s1 != null && s2 != null) {
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos al sumador</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un sumador</h1>"
+ "<div>"
+ "<p>Operador s1: " + s1 + "</p>"
+ "<p>Operador s2: " + s2 + "</p>"
+ "<p>s1 + s2: " + (Double.parseDouble(s1) + Double.parseDouble(s2)) + "</p>"
+ "</div>"
+ "</body>"
+ "</html>");
}else {
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos al sumador</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un sumador</h1>"
+ "<div>"
+ "<form action=\"suma\">"
+ "Enter 1st number: <input type=\"text\" name=s1><br>"
+ "Enter 2nd number: <input type=\"text\" name=s2><br>"
+ "<input type=\"submit\">"
+ "</form>"
+ "</div>"
+ "</body>"
+ "</html>");
}
pw.close();
}
}
package com.roshka.webprojecttest.servlets;
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;
@WebServlet("/suma-response")
public class SumaResponseServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
PrintWriter pw = new PrintWriter(resp.getOutputStream());
String s1 = req.getParameter("s1");
String s2 = req.getParameter("s2");
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos al sumador</title>"
+ "</head>"
+ "<body>"
+ "<h1>Soy un sumador</h1>"
+ "<div>"
+ "<p>Operador s1: " + s1 + "</p>"
+ "<p>Operador s2: " + s2 + "</p>"
+ "<p>s1 + s2: " + (Double.parseDouble(s1) + Double.parseDouble(s2)) + "</p>"
+ "</div>"
+ "</body>"
+ "</html>");
pw.close();
}
}
package com.roshka.webprojecttest.servlets;
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;
@WebServlet("/test1")
public class TestServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
// req -> datos que envia el navegador al servidor de aplicaciones
// resp -> la respuesta que envia el servidor de aplicaciones al navegador
PrintWriter pw = new PrintWriter(resp.getOutputStream());
pw.write("<html>"
+ "<head>"
+ "<title>Hola, bienvenidos</title>"
+ "</head>"
+ "<body>"
+ "Hola, estoy dentro del HTML"
+ "</body>"
+ "</html>");
pw.close();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment