...
 
...@@ -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
......
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
<project version="4"> <project version="4">
<component name="Encoding"> <component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component> </component>
</project> </project>
\ No newline at end of file
<?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
package com.roshka.proyectofinal; package com.roshka.proyectofinal;
import java.io.*; import jakarta.servlet.ServletException;
import java.util.*; import jakarta.servlet.http.*;
import javax.servlet.*; import java.io.*;
import javax.servlet.http.*;
public class ProtectedResource extends HttpServlet { public class ProtectedResource extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
res.setContentType("text/plain"); res.setContentType("text/plain");
PrintWriter out = res.getWriter(); PrintWriter out = res.getWriter();
......
...@@ -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>
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
<ul> <ul>
<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="./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>
...@@ -15,4 +17,5 @@ ...@@ -15,4 +17,5 @@
<a href="./formulario.html">Postulate aqui</a> <a href="./formulario.html">Postulate aqui</a>
</body> </body>
</html> </html>
\ No newline at end of file >>>>>>> origin/develop