├── README.md ├── .gitattributes ├── A2 ├── database.xml ├── style.css ├── home.html └── index.html ├── A6 ├── books.php ├── Home.html └── Login.php ├── A5 ├── Error.jsp ├── Home.jsp ├── Login.jsp ├── Register.jsp ├── web.xml ├── struts.xml ├── register.java └── validate.java ├── A1 ├── database.xml ├── style.css └── index.html ├── A3 ├── home.jsp ├── index.jsp ├── register.jsp ├── add.jsp └── validate.java ├── A4 ├── bookfetch.php ├── home.php └── login.php └── A7 ├── web.xml ├── spring-dispatcher-servlet.xml ├── StudentAdmissionController.java └── AdmissionForm.jsp /README.md: -------------------------------------------------------------------------------- 1 | # Web-Technology-Lab 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=HTML -------------------------------------------------------------------------------- /A2/database.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | abcde 4 | abcde 5 | 6 | 7 | rstuv 8 | rstuv 9 | 10 | -------------------------------------------------------------------------------- /A6/books.php: -------------------------------------------------------------------------------- 1 | { 2 | "records" : [ 3 | {"id" : "101", "title" : "WT", "price": "500"}, 4 | {"id" : "102", "title" : "SMD", "price": "300"}, 5 | {"id" : "103", "title" : "DBMS", "price": "700"} 6 | ] 7 | 8 | } 9 | -------------------------------------------------------------------------------- /A5/Error.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Error 8 | 9 | 10 | Error Occurred 11 | 12 | -------------------------------------------------------------------------------- /A5/Home.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Home 8 | 9 | 10 | Reached Home-Page 11 | 12 | -------------------------------------------------------------------------------- /A1/database.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Pencil 4 | 10 5 | 6 | 7 | Pen 8 | 20 9 | 10 | 11 | Notebook 12 | 30 13 | 14 | -------------------------------------------------------------------------------- /A2/style.css: -------------------------------------------------------------------------------- 1 | form, .form { 2 | position: fixed; 3 | top: 10%; 4 | left: 42%; 5 | } 6 | input, button { 7 | padding: 20px; 8 | margin: 20px; 9 | font-size:20px; 10 | } 11 | input::placeholder { 12 | font-size: 20px; 13 | } 14 | p { 15 | position:fixed; 16 | left: 45%; 17 | font-size: 20px; 18 | } -------------------------------------------------------------------------------- /A3/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Home 8 | 9 | 10 | Welcome to Home. 11 | You have Successfully logged in 12 | 13 | -------------------------------------------------------------------------------- /A1/style.css: -------------------------------------------------------------------------------- 1 | button { 2 | position: fixed; 3 | left: 45%; 4 | background: cyan; 5 | border-radius: 50px; 6 | font-size: 20px; 7 | } 8 | table { 9 | position: fixed; 10 | top: 10%; 11 | left: 42%; 12 | border-collapse: collapse; 13 | } 14 | table td, table th { 15 | font-size: 20px; 16 | padding: 20px; 17 | border: 1px solid black; 18 | } 19 | table th { 20 | background: cyan; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /A3/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Login 8 | 9 | 10 |
11 |
12 |
13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /A3/register.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Register 8 | 9 | 10 |
11 |
12 |
13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /A5/Login.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="/struts-tags" prefix="s" %> 4 | 5 | 6 | 7 | 8 | Login 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /A5/Register.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@ taglib uri="/struts-tags" prefix="s" %> 4 | 5 | 6 | 7 | 8 | Register 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /A3/add.jsp: -------------------------------------------------------------------------------- 1 | <%@ page 2 | import="java.sql.*" 3 | %> 4 | 5 | <% 6 | String user =request.getParameter("user"); 7 | String pass =request.getParameter("pass"); 8 | 9 | Class.forName("com.mysql.jdbc.Driver"); 10 | Connection con = DriverManager.getConnection("jdbc:mysql://localhost/comp","root","rootpasswordgiven"); 11 | Statement smt = con.createStatement(); 12 | int i = smt.executeUpdate("insert into account values('"+user+"','"+pass+"')"); 13 | if(i>0) 14 | { 15 | %> 16 | 20 | <% 21 | } 22 | %> -------------------------------------------------------------------------------- /A4/bookfetch.php: -------------------------------------------------------------------------------- 1 | IDTitlePrice"; 12 | 13 | while($row = mysqli_fetch_array($result)) { 14 | echo ""; 15 | echo "" . $row['id'] . ""; 16 | echo "" . $row['title'] . ""; 17 | echo "" . $row['price'] . ""; 18 | echo ""; 19 | } 20 | echo ""; 21 | mysqli_close($con); 22 | ?> -------------------------------------------------------------------------------- /A7/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Spring 4 | 5 | spring-dispatcher 6 | org.springframework.web.servlet.DispatcherServlet 7 | 8 | 9 | 10 | spring-dispatcher 11 | / 12 | 13 | -------------------------------------------------------------------------------- /A4/home.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | AJAX 4 | 16 | 17 | 18 | 23 |
24 | 25 | -------------------------------------------------------------------------------- /A5/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | S 4 | 5 | Login.jsp 6 | 7 | 8 | Struts2 9 | org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 10 | 11 | 12 | 13 | Struts2 14 | /* 15 | 16 | -------------------------------------------------------------------------------- /A5/struts.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | /Home.jsp 9 | /Login.jsp 10 | 11 | 12 | 13 | 14 | /Login.jsp 15 | /Error.jsp 16 | 17 | 18 | -------------------------------------------------------------------------------- /A6/Home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 | {{welcome}} 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
IDTitlePrice
{{x.id}}{{x.title}}{{x.price}}
21 |
22 | 23 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /A1/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | HTML,CSS,XML 4 | 5 | 6 | 7 | 8 |
9 | 27 | 28 | -------------------------------------------------------------------------------- /A6/Login.php: -------------------------------------------------------------------------------- 1 | 0) 17 | { 18 | header('Location: Home.html'); 19 | } 20 | else 21 | { 22 | echo ""; 23 | } 24 | } 25 | mysqli_close($con); 26 | } 27 | 28 | ?> 29 | 30 | 31 | Login 32 | 33 | 34 |
35 | 36 | 37 | 38 | 39 | 40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /A5/register.java: -------------------------------------------------------------------------------- 1 | package varun; 2 | import java.sql.Connection; 3 | import java.sql.DriverManager; 4 | import java.sql.Statement; 5 | 6 | import com.opensymphony.xwork2.ActionSupport; 7 | public class register extends ActionSupport 8 | { 9 | private static final long serialVersionUID = 1L; 10 | private String username; 11 | private String password; 12 | 13 | public String execute() throws Exception 14 | { 15 | Class.forName("com.mysql.jdbc.Driver"); 16 | Connection con = DriverManager.getConnection("jdbc:mysql://localhost/comp", "root", "rootpasswordgiven"); 17 | Statement st = con.createStatement(); 18 | int id = st.executeUpdate("insert into account values('"+username+"','"+password+"')"); 19 | 20 | if(id>0) 21 | return "success"; 22 | else 23 | return "failure"; 24 | } 25 | public String getUsername() { return username;} 26 | public void setUsername(String username) {this.username = username;} 27 | public String getPassword() { return password; } 28 | public void setPassword(String password) {this.password = password;} 29 | 30 | } -------------------------------------------------------------------------------- /A7/spring-dispatcher-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | / 20 | 21 | 22 | .jsp 23 | 24 | 25 | -------------------------------------------------------------------------------- /A2/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Home 4 | 5 | 6 | 7 |

Syntax Validator

8 |

9 |
10 |
11 |
12 | 13 |
14 | 43 | 44 | -------------------------------------------------------------------------------- /A2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | ValidateJS 4 | 5 | 6 | 7 |
8 |
9 |
10 | 11 |
12 | 41 | 42 | -------------------------------------------------------------------------------- /A5/validate.java: -------------------------------------------------------------------------------- 1 | package varun; 2 | import java.sql.Connection; 3 | import java.sql.DriverManager; 4 | import java.sql.ResultSet; 5 | import java.sql.Statement; 6 | 7 | import com.opensymphony.xwork2.Action; 8 | import com.opensymphony.xwork2.ActionSupport; 9 | public class validate extends ActionSupport implements Action 10 | { 11 | private static final long serialVersionUID = 1L; 12 | private String username; 13 | private String password; 14 | public String FailMsg = "Please Enter Valid Credentials ..."; 15 | 16 | public String execute() throws Exception 17 | { 18 | Class.forName("com.mysql.jdbc.Driver"); 19 | Connection con = DriverManager.getConnection("jdbc:mysql://localhost/comp", "root", "rootpasswordgiven"); 20 | Statement st = con.createStatement(); 21 | ResultSet rs = st.executeQuery("select * from account"); 22 | while(rs.next()) 23 | { 24 | if(username.equals(rs.getString("username")) && password.equals(rs.getString("password"))) 25 | return "login"; 26 | } 27 | return "error"; 28 | } 29 | 30 | public String getUsername() { 31 | return username; 32 | } 33 | public void setUsername(String username) { 34 | this.username = username; 35 | } 36 | public String getPassword() { 37 | return password; 38 | } 39 | public void setPassword(String password) { 40 | this.password = password; 41 | } 42 | } -------------------------------------------------------------------------------- /A7/StudentAdmissionController.java: -------------------------------------------------------------------------------- 1 | package varun; 2 | import java.util.Map; 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.PathVariable; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | import org.springframework.web.servlet.ModelAndView; 9 | @Controller 10 | public class StudentAdmissionController 11 | { 12 | @RequestMapping(value="/admissionForm", method=RequestMethod.GET) 13 | protected ModelAndView myMethod1() 14 | { 15 | ModelAndView mv=new ModelAndView("AdmissionForm"); 16 | return mv; 17 | } 18 | 19 | @RequestMapping(value="/submitAdmissionForm", method=RequestMethod.POST) 20 | protected ModelAndView myMethod2( 21 | @RequestParam("studentname") String name, 22 | @RequestParam("password") String password, 23 | @RequestParam("mobile") String mobile, 24 | @RequestParam("email") String email, 25 | @RequestParam("age") String age) 26 | { 27 | ModelAndView mv=new ModelAndView("AdmissionSuccess"); 28 | mv.addObject("WelcomeMessage","Details are :
Name :"+name+"
Password: "+password+"
Mobile No : " 29 | +mobile + "
E-Mail : "+email+"
Age : "+age); 30 | return mv; 31 | } 32 | } -------------------------------------------------------------------------------- /A4/login.php: -------------------------------------------------------------------------------- 1 | window.open('home.php'); "; 36 | } 37 | else 38 | { 39 | echo ""; 40 | } 41 | } 42 | mysqli_close($con); 43 | } 44 | 45 | ?> 46 | 47 | 48 | 49 | PHP, AJAX, Mysql 50 | 51 | 52 |
53 | 54 | 55 | 56 | 57 | 58 |
59 | 60 | -------------------------------------------------------------------------------- /A7/AdmissionForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | 5 | 6 | Insert title here 7 | 8 | 9 | 10 | 11 |

Student Admission Form

12 |
13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 | 26 |
27 | 28 | 29 |
30 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /A3/validate.java: -------------------------------------------------------------------------------- 1 | 2 | import java.io.IOException; 3 | import java.io.PrintWriter; 4 | import java.sql.Connection; 5 | import java.sql.DriverManager; 6 | import java.sql.ResultSet; 7 | import java.sql.Statement; 8 | import javax.servlet.RequestDispatcher; 9 | import javax.servlet.ServletException; 10 | import javax.servlet.annotation.WebServlet; 11 | import javax.servlet.http.HttpServlet; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | 15 | @WebServlet("/validate") 16 | public class validate extends HttpServlet 17 | { 18 | private static final long serialVersionUID = 1L; 19 | 20 | protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 21 | { 22 | String user = request.getParameter("user"); 23 | String pass = request.getParameter("pass"); 24 | boolean flag = false; 25 | 26 | try 27 | { 28 | Class.forName("com.mysql.jdbc.Driver"); 29 | Connection con = DriverManager.getConnection("jdbc:mysql://localhost/comp","root","rootpasswordgiven"); 30 | Statement stm = con.createStatement(); 31 | ResultSet res = stm.executeQuery("SELECT * FROM account"); 32 | while(res.next()) { 33 | String u = res.getString("username"); 34 | String p = res.getString("password"); 35 | if(user.equals(u) && pass.equals(p)) 36 | { 37 | flag = true; 38 | break; 39 | } 40 | } 41 | con.close(); 42 | } 43 | catch (Exception e) 44 | { 45 | e.printStackTrace(); 46 | } 47 | 48 | if (flag == true) 49 | { 50 | RequestDispatcher r = request.getRequestDispatcher("home.jsp"); 51 | r.forward(request, response); 52 | } 53 | else 54 | { 55 | response.setContentType("text/html"); 56 | PrintWriter out = response.getWriter(); 57 | out.println(""+user+pass); 58 | RequestDispatcher r = request.getRequestDispatcher("index.jsp"); 59 | r.include(request, response); 60 | } 61 | } 62 | } --------------------------------------------------------------------------------