Jsp Lab Project

  • Uploaded by: seenu
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Jsp Lab Project as PDF for free.

More details

  • Words: 412
  • Pages: 5
Jsp

<%@ page language="java" import="java.util.*" pageEncoding="ISO-88591"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServer Port()+path+"/"; %> My JSP 'MyJsp.jsp' starting page <meta <meta <meta <meta <meta

http-equiv="pragma" content="no-cache"> http-equiv="cache-control" content="no-cache"> http-equiv="expires" content="0"> http-equiv="keywords" content="keyword1,keyword2,keyword3"> http-equiv="description" content="This is my page"> rel="stylesheet" type="text/css" href="styles.css">

This is my JSP page.


Userid 
  
     pass      
 
         ;           &nbs p;         




Servlet import java.io.IOException;

import java.io.PrintWriter; import import import import import import import

javax.servlet.RequestDispatcher; javax.servlet.ServletException; javax.servlet.http.HttpServlet; javax.servlet.http.HttpServletRequest; javax.servlet.http.HttpServletResponse; Mypack.*; java.sql.*;

public class Myservlet extends HttpServlet { String s,s1,s2; /** * Constructor of the object. */ public Myservlet() { super(); } /** * Destruction of the servlet.
*/ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doPost method of the servlet.
* * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); Connection con; s=request.getParameter("t1"); s1=request.getParameter("t2"); Data d=new Data(); con=d.cc(); try { PreparedStatement ps=con.prepareStatement("select password from user1 where username=? "); ps.setString(1, s); ResultSet rs=ps.executeQuery(); while(rs.next())

{

s2=rs.getString(1); } }catch(SQLException x) { System.out.println(x); } if(s1.equals(s2)) { RequestDispatcher rd=request.getRequestDispatcher("/first.jsp"); rd.forward(request, response); } else { RequestDispatcher rd=request.getRequestDispatcher("/MyJsp.jsp"); rd.include(request, response); out.print("user and password are invalid"); } } /** * Initialization of the servlet.
* * @throws ServletException if an error occure */ public void init() throws ServletException { // Put your code here } }

Data pacakage

package Mypack; import java.sql.*; public class Data { Connection con; public Connection cc() { try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("Jdbc:Odbc: stu"); }catch(ClassNotFoundException c) { c.printStackTrace(); }catch(SQLException s){ s.printStackTrace(); } return con; } }

First jsp

<%@ page language="java" import="java.util.*" pageEncoding="ISO-88591"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServer Port()+path+"/"; %> My JSP 'first.jsp' starting page <meta <meta <meta <meta <meta

http-equiv="pragma" content="no-cache"> http-equiv="cache-control" content="no-cache"> http-equiv="expires" content="0"> http-equiv="keywords" content="keyword1,keyword2,keyword3"> http-equiv="description" content="This is my page"> rel="stylesheet" type="text/css" href="styles.css">

This is my JSP page.

sucesssssssssss

Related Documents

Jsp Lab Project
November 2019 30
Jsp
April 2020 36
Jsp
May 2020 27
Jsp
May 2020 14
Jsp
May 2020 14
Jsp
July 2020 16

More Documents from ""

Java Collection Classes
November 2019 26
Jdbc
November 2019 31
Struts Tutorial
November 2019 16
Scjp 5 Mockup Test With Q&a
November 2019 22
Jsp Lab Project
November 2019 30