Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.shubh;
- import java.io.IOException;
- import java.sql.*;
- import java.io.*;
- import javax.servlet.ServletException;
- import javax.servlet.annotation.WebServlet;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- public class Download extends HttpServlet {
- private static final long serialVersionUID = 1L;
- public Download() {
- super();
- // TODO Auto-generated constructor stub
- }
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- // TODO Auto-generated method stub
- Connection con;
- Statement s;
- ResultSet r;
- try{
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- String url="jdbc:mysql://localhost:3306/";
- String user="sky";
- String pass="root123";
- String dbname="student";
- con=DriverManager.getConnection(url+dbname, user, pass);
- String password=request.getParameter("password");
- String loginid=request.getParameter("login");
- String query="select * from login where password='"+password+"' and loginid='"+loginid+"'";
- s=con.createStatement();
- r=s.executeQuery(query);
- if(r.next())
- {
- response.setContentType("text/html");
- PrintWriter out=response.getWriter();
- out.println("<html>");
- out.println("<body>");
- out.println(loginid+password);
- out.println("</html>");
- out.println("</body>");
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement