Commit 61e49c50 by Jose Baez

Merge branch 'crearBootcamp' into 'develop'

Crear bootcamp

See merge request !14
parents 026d518c 32f2dd4a
...@@ -4,6 +4,7 @@ target/ ...@@ -4,6 +4,7 @@ target/
!**/src/test/**/target/ !**/src/test/**/target/
### IntelliJ IDEA ### ### IntelliJ IDEA ###
.idea/encodings.xml
.idea/** .idea/**
.idea/modules.xml .idea/modules.xml
.idea/jarRepositories.xml .idea/jarRepositories.xml
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="" vcs="Git" />
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -10,7 +10,7 @@ public class DataBase { ...@@ -10,7 +10,7 @@ public class DataBase {
try{ try{
Class.forName("org.postgresql.Driver"); Class.forName("org.postgresql.Driver");
con= DriverManager con= DriverManager
.getConnection("jdbc:postgresql://localhost:5432/Bootcamp_th", .getConnection("jdbc:postgresql://localhost:5432/bootcamp_th",
"postgres", "postgres"); "postgres", "postgres");
if(con != null){ if(con != null){
......
package com.roshka.proyectofinal;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.*;
@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet extends HttpServlet {
private String message="HOLA";
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("text/html");
// Hello
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("<h1>" + message + "</h1>");
out.println("</body></html>");
}
public void destroy() {
}
}
\ No newline at end of file
...@@ -8,6 +8,14 @@ public class Lenguaje { ...@@ -8,6 +8,14 @@ public class Lenguaje {
} }
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getNombre_lenguaje() { public String getNombre_lenguaje() {
return nombre_lenguaje; return nombre_lenguaje;
} }
......
...@@ -2,9 +2,14 @@ package com.roshka.proyectofinal.lenguaje; ...@@ -2,9 +2,14 @@ package com.roshka.proyectofinal.lenguaje;
import com.roshka.proyectofinal.DataBase; import com.roshka.proyectofinal.DataBase;
import com.roshka.proyectofinal.entity.Lenguaje; import com.roshka.proyectofinal.entity.Lenguaje;
import jakarta.servlet.RequestDispatcher;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class LenguajeDao { public class LenguajeDao {
...@@ -23,4 +28,25 @@ public class LenguajeDao { ...@@ -23,4 +28,25 @@ public class LenguajeDao {
return status; return status;
} }
}
public static List<Lenguaje> listar(){
ArrayList<Lenguaje>list = new ArrayList<>();
String sql = "select * from lenguaje";
try{
Connection con= DataBase.getConnection();
PreparedStatement ps=con.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
while(rs.next()){
Lenguaje len = new Lenguaje();
len.setId(rs.getInt("id"));
len.setNombre_lenguaje(rs.getString("nombre_lenguaje"));
list.add(len);
}
con.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
return list;
}
}
package com.roshka.proyectofinal.lenguaje;
import com.roshka.proyectofinal.entity.Lenguaje;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/ProyectoFinal-Bootcamp/crearBootcamp")
public class ObtenerLenguaje extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
List<Lenguaje> len = LenguajeDao.listar();
request.setAttribute("listaLenguaje", len);
RequestDispatcher rqd = request.getRequestDispatcher("./formulario_bootcamp.jsp");
rqd.forward(request, response);
}
}
...@@ -10,6 +10,7 @@ import java.io.IOException; ...@@ -10,6 +10,7 @@ import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
public class SaveServlet extends HttpServlet { public class SaveServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { throws ServletException, IOException {
response.setContentType("text/html"); response.setContentType("text/html");
......
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/bootstrap.css" rel="stylesheet" type="text/css"/>
<title>JSP Page</title>
</head>
<body>
<div class="container">
<h1>Crear Bootcamp</h1>
<%@ page import="com.roshka.proyectofinal.entity.Lenguaje, com.roshka.proyectofinal.lenguaje.LenguajeDao, java.util.List,java.util.Iterator" %>
<%
LenguajeDao lenDao = new LenguajeDao();
List<Lenguaje> listLenguaje = lenDao.listar();
Iterator<Lenguaje> iter = listLenguaje.iterator();
Lenguaje len = null;
%>
<form action="" method="post">
<label for="lenguaje">Lenguajes:</label>
<select name="lenguaje" id="lenguaje">
<% while(iter.hasNext()){
len = iter.next();
%>
<option value=<%= len.getId() %> >
<%= len.getNombre_lenguaje() %>
</option>
<% } %>
</select>
</form>
</div>
</body>
</html>
...@@ -27,9 +27,10 @@ ...@@ -27,9 +27,10 @@
</div> </div>
<div class="menu"> <div class="menu">
<ul> <ul>
<li class="link-menu"><a href="formulario.html">Postulate</a></li>
<li class="link-menu"><a href="/">Home</a></li> <li class="link-menu"><a href="/">Home</a></li>
<li class="link-menu"><a href="./home.html">Postulate</a></li>
<li class="link-menu"><a href="/ProyectoFinal-Bootcamp/crearBootcamp">Crear bootcamp</a>
</li>
</ul> </ul>
</div> </div>
<!-- menu --> <!-- menu -->
......
<<<<<<< HEAD
=======
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
...@@ -16,3 +18,4 @@ ...@@ -16,3 +18,4 @@
</body> </body>
</html> </html>
>>>>>>> origin/develop
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