SERVLETS AND JDBC.

Slides:



Advertisements
Similar presentations
Apache Tomcat as a container for Servlets and JSP
Advertisements

 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
COMP 321 Week 8. Overview MVC Example Servlet Lifecycle Servlet Mechanics MVC Lab 5-2 Solution Lab 8-1 Introduction.
1 CS6320 – Servlet Request Dispatcher L. Grewe 2 What is the purpose Forward a request from one servlet to another (or jsp). Forward a request from one.
Servlets. A form The HTML source Chapter 1 Please enter your name and password then press start Name: Password: In Netbeans you can graphically create.
Objectives Ch. D - 1 At the end of this chapter students will: Know the general architecture and purpose of servlets Understand how to create a basic servlet.
Servlets Stoney Jackson
Servlets. A form The HTML source Chapter 1 Please enter your name and password then press start Name: Password: In Netbeans you can graphically create.
2/16/2004 Dynamic Content February 16, /16/2004 Assignments Due – Message of the Day Part 1 Due – Reading and Warmup Work on Message of the Day.
27-Jun-15 Directories and DDs. 2 Web apps A web application is basically a web site that: “Knows who you are”--it doesn’t just give you static pages,
Java database Programming JDBC Trademarked name of a Java API that supports Java programs that access relational databases Stand for Java DataBase Connectivity.
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
Java Servlet. What is Java Servlet? A Servlet is a java based server side web technology. It is a java class that serves a client request and receives.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Examples of Using Servlets and JSP Representation and Management of Data on the Internet.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
DataBases and SQL INFSY 547 Spring Course Wrap Up April 12: Complete Work on Servlets Review of Team Projects Close of Portfolio Work April 19:
Servlets Database Access. Agenda:  Setup Java Environment  Install Database  Install Database Drivers  Create Table and add records  Accessing a.
Mark Dixon 1 09 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
JSP Presented by K.Venkata Ratnam HOD MCA (Dept) Newton’s Institute of Engineering.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
S ERVLETS Hits Counter 21-Nov-15. S ERVLETS - H ITS C OUNTER Many times you would be interested in knowing total number of hits on a particular page of.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session II: Introduction to Server-Side Web Development with Servlets.
Top right corner for field-mark, customer or partner logotypes. See Best practice for example. Slide title 40 pt Slide subtitle 24 pt Text 24 pt Bullets.
Hints for Assignment #8. Initial Screen Hints for the initial page You need a DOCTYPE with the proper namespaces defined You need to import the facebook.
 2002 Prentice Hall. All rights reserved. 9.8 Multi-Tier Applications: Using JDBC from a Servlet Three-tier distributed applications –User interface –Business.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
Mark Dixon 1 11 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
Introduction to Servlets. Introduction Servlet is a language to develop the server side applications, and it is also server side component. It can develop.
Configuration Web Server Tomcat - Install JDK Install Tom cat Configure Tom cat for running Servlet C:\Program Files\Apache Software Foundation\Tomcat.
Introduction To HTML Dr. Magdi AMER. HTML elements.
Web Programming Assistant Professor Xiaozhong Liu
 Java Server Pages (JSP) By Offir Golan. What is JSP?  A technology that allows for the creation of dynamically generated web pages based on HTML, XML,
CS 562 Advanced Java and Internet Application Computer Warehouse Web Application By Team Alpha :-  Puja Mehta (102163)  Mona Nagpure (102147)
Web Programming: Loop Xiaozhong Liu
Programming with Java Lecture 6 Elements of a Java Servlet
Introduction to Servlets
Introduction to Servlets
J2EE (Enterprise Programing)
Principles of Software Development
PERTEMUAN 3.
PERTEMUAN 2.
Net-centric Computing
JDBC & Servlet CSE 4504/6504 Lab.
Servlets Hits Counter 20-Jul-18.
Session Tracking in Servlets
HTTP Servlet Overview Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For example, a servlet might.
Sessions.
In Class Assg 4 - Solution
In Class Assg 3 - Solution
Servlet.
Jagdish Gangolly State University of New York at Albany
Servlets and Java Server Pages
Servlets and JSP 20-Nov-18 servletsJSP.ppt.
Servlets CEN /28/2018 Copyright 2001 Ege Consulting, Inc.
In Class Assg 2 - solution
© copyright Janson Industries 2011
Handling FORM Data using Servlets
Web Search Interfaces.
Web Search Interfaces by Ray Mooney
Servlets.
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Java Servlets Servlet Overview Servlets and HTML Forms Servlet Basics
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Directories and DDs 25-Apr-19.
Basic servlet structure
Directories and DDs 21-Jul-19.
Servlets: Servlet / Web Browser Communication I
Directories and DDs 14-Sep-19.
Presentation transcript:

SERVLETS AND JDBC

USER REGISTRATION

Database Creation create table Student ( name varchar2(20), email varchar2(30), pass varchar2(20) );

HTML FORM <html> <head> <title>Register form</title> </head> <body> <form method="post" action=“Register"> Name:<input type="text" name="name" /><br/> Email ID:<input type="text" name="email" /><br/> Password:<input type="text" name="pass" /><br/> <input type="submit" value="register" /> </form> </body> </html>

Servlet Code (MYSQL DB) public class Register extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); String name = request.getParameter("name"); String email = request.getParameter("email"); String pass = request.getParameter("pass"); try{ Class.forName("com.mysql.jdbc.Driver"); //MYSQL DATABASE Connection con=DriverManager.getConnection ("jdbc:mysql:/ /localhost:3306/test","username","password"); PreparedStatement ps=con.prepareStatement ("insert into Student values(?,?,?)"); ps.setString(1, name); ps.setString(2, email); ps.setString(3, pass); int i=ps.executeUpdate(); if(i>0) { out.println("You are sucessfully registered"); } } catch(Exception se) { se.printStackTrace(); } } }

Servlet Code(ORACLE DB) public class Register extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); String name = request.getParameter("name"); String email = request.getParameter("email"); String pass = request.getParameter("pass"); try{Class.forName("oracle.jdbc.driver.OracleDriver"); //ORACLE DATABASE Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", “scott",“tiger"); PreparedStatement ps=con.prepareStatement ("insert into Student values(?,?,?)"); ps.setString(1, name); ps.setString(2, email); ps.setString(3, pass); int i=ps.executeUpdate(); if(i>0) { out.println("You are sucessfully registered"); } } catch(Exception se) { se.printStackTrace(); } } }

DEMO