Commit e6a97d25 by roshka

1.0

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="WebContent"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
org.eclipse.jdt.core.compiler.compliance=10
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=10
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name=" jweb-e001">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="context-root" value="_jweb-e001"/>
<property name="java-output-path" value="/ jweb-e001/build/classes"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Apache Tomcat v9.0"/>
<fixed facet="wst.jsdt.web"/>
<fixed facet="java"/>
<fixed facet="jst.web"/>
<installed facet="java" version="10"/>
<installed facet="jst.web" version="4.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Manifest-Version: 1.0
Class-Path:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Agenda</title>
</head>
<body>
<h1>Ingrese los datos del cliente</h1>
<form action="guardar" method="post">
<label for="nombre">Nombre: </label>
<input type="text" name="P0" id="nombre"><br><br>
<label for="correo">Correo electronico: </label>
<input type="email" id="correo" name="P1"><br><br>
<label for="telefono">Telefono: </label>
<input type="text" name="P3" id="telefono"><br><br>
<label for="direccion">Dirección: </label>
<input type="text" name="P4" id="direccion"><br><br>
<input type="submit" value="Guardar">
</form><br><br>
<a href="http://localhost:8080/_jweb-e001/index.html">Volver al menu principal</a>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Obten tu carta de poker</title>
</head>
<body>
<h1>Ingrese el palo y el valor de la carta</h1>
<form action="dibujo_carta" method="get">
<label for="palo_carta">Palo: </label>
<input type="text" id="palo_carta" name="P0"><br><br>
<label for="valor_carta">Valor: </label>
<input type="text" id="valor_carta" name="P1"><br><br>
<input type="submit" value="Obtener carta">
</form>
<p>
Palos posibles:<br>
* S : Picas (Spades)<br>
* H : Corazones (Hearts)<br>
* C : Treboles (Clubs)<br>
* D : Diamante (Diamonds)
</p>
<p>
Valores posibles: 1 al 13.<br>
* 1 equivale al As <br>
* 11 equivale al J <br>
* 12 equivale al Q <br>
* 13 equivales al K
</p><br><br>
<a href="http://localhost:8080/_jweb-e001/index.html">Volver al menu principal</a>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Conversor de temperatura</title>
</head>
<body>
<h1>Ingrese los datos</h1>
<form action="conversor_temperatura" method="post">
<label for="valor̲temperatura">Temperatura: </label>
<input type="text" name="P1" id="valor̲temperatura"><br><br>
<label for="tipo̲temperatura">Tipo de temperatura</label>
<select name="P0" id="tipo̲temperatura">
<option value="0">C</option>
<option value="1">F</option>
<option value="2">K</option>
</select><br><br>
<input type="submit" value="Calcular">
</form><br><br>
<a href="http://localhost:8080/_jweb-e001/index.html">Volver al menu principal</a>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Menu principal</title>
</head>
<body>
<h1>Menu principal</h1>
<a href="http://localhost:8080/_jweb-e001/agenda.html">Agenda</a><br><br>
<a href="http://localhost:8080/_jweb-e001/conversor.html">Conversor de temperaturas</a><br><br>
<a href="http://localhost:8080/_jweb-e001/cartas.html">Mostrar carta poker</a><br><br>
</body>
</html>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-10-oracle">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v9.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jweb-e001</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
<linkedResources>
<link>
<name>WebContent/cartas</name>
<type>2</type>
<location>/home/hugo/eclipse-workspace/ jweb-e001/WebContent/cartas</location>
</link>
</linkedResources>
</projectDescription>
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 conversor_temperatura
*/
@WebServlet("/conversor_temperatura")
public class conversor_temperatura extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public conversor_temperatura() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter escribir = response.getWriter();
try {
double fahrenheit;
double celsius;
double kelvin;
double entrada = Double.parseDouble(request.getParameter("P1"));
double selector = Double.parseDouble(request.getParameter("P0"));
if(selector == 0) {
//Esto es si la temperatura esta en celsius
celsius = entrada;
fahrenheit = (entrada * 9/5) + 32;
kelvin = entrada + 273.15;
escribir.append(
"<!DOCTYPE html>\n" +
"<html>\n" +
"<head>\n" +
" <meta charset=\"UTF-8\">\n" +
" <title>Resultado temperaturas</title>\n" +
" </head>\n" +
"<body>\n" +
" <h1>Los resultados son</h1>\n" +
" <p>Celsius: "+celsius+"</p>\n" +
" <p>Fahrenheit: "+fahrenheit+"</p>\n" +
" <p>Kelvin: "+kelvin+"</p><br><br>\n" +
"<a href=\"http://localhost:8080/_jweb-e001/conversor.html\">Volver al conversor de temperaturas</a><br><br> " +
"<a href=\"http://localhost:8080/_jweb-e001/index.html\">Volver al menu principal</a><br><br> " +
"</body>\n" +
"</html>"
);
}else if(selector == 1) {
//Esto es si la temperatura esta en fahrenheit
celsius = (entrada - 32) * 5/9;
fahrenheit = entrada;
kelvin =((entrada - 32)*5/9) + 273.15;
escribir.append(
"<!DOCTYPE html>\n" +
"<html>\n" +
"<head>\n" +
" <meta charset=\"UTF-8\">\n" +
" <title>Resultado temperaturas</title>\n" +
" </head>\n" +
"<body>\n" +
" <h1>Los resultados son</h1>\n" +
" <p>Celsius: "+celsius+"</p>\n" +
" <p>Fahrenheit: "+fahrenheit+"</p>\n" +
" <p>Kelvin: "+kelvin+"</p><br><br>\n" +
"<a href=\"http://localhost:8080/_jweb-e001/conversor.html\">Volver al conversor de temperaturas</a><br><br> " +
"<a href=\"http://localhost:8080/_jweb-e001/index.html\">Volver al menu principal</a><br><br> " +
"</body>\n" +
"</html>"
);
}else if(selector == 2) {
//Esto es si la temperatura esta en kelvin
celsius = entrada - 273.15;
fahrenheit = ((entrada - 273.15)*9/5)+32;
kelvin =entrada;
escribir.append(
"<!DOCTYPE html>\n" +
"<html>\n" +
"<head>\n" +
" <meta charset=\"UTF-8\">\n" +
" <title>Resultado temperaturas</title>\n" +
" </head>\n" +
"<body>\n" +
" <h1>Los resultados son:</h1>\n" +
" <p>Celsius: "+celsius+"</p>\n" +
" <p>Fahrenheit: "+fahrenheit+"</p>\n" +
" <p>Kelvin: "+kelvin+"</p><br><br>\n" +
"<a href=\"http://localhost:8080/_jweb-e001/conversor.html\">Volver al conversor de temperaturas</a><br><br> " +
"<a href=\"http://localhost:8080/_jweb-e001/index.html\">Volver al menu principal</a><br><br> " +
"</body>\n" +
"</html>"
);
}
}catch(Exception e) {
escribir.append(
"<!DOCTYPE html>\n" +
"<html>\n" +
"<head>\n" +
" <meta charset=\"UTF-8\">\n" +
" <title>Resultado temperaturas</title>\n" +
" </head>\n" +
"<body>\n" +
" <h1>Los resultados son:</h1>\n" +
" <p>La entrada solo admite numeros</p>\n" +
"<a href=\"http://localhost:8080/_jweb-e001/conversor.html\">Volver al conversor de temperaturas</a><br><br> " +
"<a href=\"http://localhost:8080/_jweb-e001/index.html\">Volver al menu principal</a><br><br> " +
"</body>\n" +
"</html>"
);
}
}
}
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(
"<!DOCTYPE html>\n" +
"<html>\n" +
"<head>\n" +
"<meta charset=\"UTF-8\">\n" +
"<title>Agenda</title>\n" +
"</head>\n" +
"<body>\n" +
" <h1>Tu carta es: </h1>\n" +
" <img src=\"cartas/"+ valor + palo + ".png"+"\" alt=\"Resultado carta\" width=\"227\" height=\"315\"><br><br>\n" +
" <a href=\"http://localhost:8080/_jweb-e001/cartas.html\">Volver al selector de carta</a><br><br>" +
" <a href=\"http://localhost:8080/_jweb-e001/index.html\">Volver al menu principal</a>" +
"</body>\n" +
"</html>"
);
}else {
escribirPagina.append(
"<!DOCTYPE html>\n" +
"<html>\n" +
"<head>\n" +
"<meta charset=\"UTF-8\">\n" +
"<title>Agenda</title>\n" +
"</head>\n" +
"<body>\n" +
" <p>El campo valor solo admite valores entre entre el 1 y el 13</p><br><br>\n" +
" <a href=\"http://localhost:8080/_jweb-e001/cartas.html\">Volver al selector de carta</a><br><br>\n" +
" <a href=\"http://localhost:8080/_jweb-e001/index.html\">Volver al menu principal</a>" +
"</body>\n" +
"</html>"
);
}
}else {
escribirPagina.append(
"<!DOCTYPE html>\n" +
"<html>\n" +
"<head>\n" +
"<meta charset=\"UTF-8\">\n" +
"<title>Agenda</title>\n" +
"</head>\n" +
"<body>\n" +
" <p>El campo del palo solo admite valores:<br>* S<br>* H<br>* C<br>* D</p><br><br>\n" +
" <a href=\"http://localhost:8080/_jweb-e001/cartas.html\">Volver al selector de carta</a><br><br>\n" +
" <a href=\"http://localhost:8080/_jweb-e001/index.html\">Volver al menu principal</a>" +
"</body>\n" +
"</html>"
);
}
}catch(NumberFormatException e){
escribirPagina.append(
"<!DOCTYPE html>\n" +
"<html>\n" +
"<head>\n" +
"<meta charset=\"UTF-8\">\n" +
"<title>Agenda</title>\n" +
"</head>\n" +
"<body>\n" +
" <p>El campo del valor solo admite numeros enteros</p><br><br>\n" +
" <a href=\"http://localhost:8080/_jweb-e001/cartas.html\">Volver al selector de carta</a><br><br>" +
" <a href=\"http://localhost:8080/_jweb-e001/index.html\">Volver al menu principal</a>" +
"</body>\n" +
"</html>"
);
}
}
/**
* @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);
}
}
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 guardar_en_agenda
*/
@WebServlet("/guardar")
public class guardar extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public guardar() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int contador = 1;
File carpetaClientes = new File("./lista_personas");
if(!carpetaClientes.exists()) {
carpetaClientes.mkdir();
}
PrintWriter escribirNavegador = response.getWriter();
//Esto es para encontrar el archivo
String direccionArchivo = "./lista_personas/" + contador + ".txt";
File archivo = new File(direccionArchivo);
while(archivo.isFile()) {
direccionArchivo = "./lista_personas/" + contador + ".txt";
archivo = new File(direccionArchivo);
contador = contador + 1;
}
//Creamos el archivo
archivo.createNewFile();
try {
//Preparamos los datos
PrintWriter escribirArchivo = new PrintWriter(archivo);
String nombre = request.getParameter("P0");
String correo = request.getParameter("P1");
String telefono = request.getParameter("P3");
String direccion = request.getParameter("P4");
nombre = nombre.toUpperCase();
//cargamos el archivo
escribirArchivo.println(nombre + " " + correo + " " + telefono + " "+direccion);
escribirArchivo.close();
escribirNavegador.append(
"<!DOCTYPE html>\n" +
"<html>\n" +
"<head>\n" +
" <meta charset=\"UTF-8\">\n" +
" <title>Log guardado</title>\n" +
" </head>\n" +
"<body>\n" +
" <p>Los datos se cargaron correctamente</p><br><br>\n" +
" <a href=\"http://localhost:8080/_jweb-e001/agenda.html\">Cargar una nueva persona</a><br><br>" +
" <a href=\"http://localhost:8080/_jweb-e001/index.html\">Volver al menu principal</a>" +
"</body>\n" +
"</html>"
);
}catch (Exception e) {
escribirNavegador.append("<!DOCTYPE html>\n" +
"<html>\n" +
"<head>\n" +
" <meta charset=\"UTF-8\">\n" +
" <title>Log guardado</title>\n" +
" </head>\n" +
"<body>\n" +
" <p>"+ e.getMessage()+"</p><br><br>\n" +
" <a href=\"http://localhost:8080/_jweb-e001/agenda.html\">Volver a cargar a la persona</a><br><br>" +
" <a href=\"http://localhost:8080/_jweb-e001/index.html\">Volver al menu principal</a>" +
"</body>\n" +
"</html>"
);
}
}
}
# A tomar en cuenta
1. Los enlaces son los siguientes:
- Cartas: localhost:8080/_jweb-e001/cartas.html
- Convertidor de temperaturas: http://localhost:8080/_jweb-e001/conversor.html
- Agenda: http://localhost:8080/_jweb-e001/agenda.html
- Pagina principal: http://localhost:8080/_jweb-e001/index.html
2. Los archivos generados en agenda son almacenadas en la carpeta "lista_personas", y la misma se genera donde se ejecuta el servidor apache, es decir, en mi caso, se crea la carpeta y se crea los archivos en la carpeta de la aplicación de eclipse, que tiene la direccion, en mi caso: /home/hugo/Eclipse-2018-09/eclipse/lista_personas
3. Las imagenes de las cartas estan almacenadas en el "WebContent", en la carpeta "cartas".
4. La carpeta 'jweb-e001' contiene el proyecto, y se hizo con la aplicacion eclipse.
File added
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