Quick Introduction to Java Servlets/NSJSP in the NonStop Environment HH676S B.00. Student guide

Size: px
Start display at page:

Download "Quick Introduction to Java Servlets/NSJSP in the NonStop Environment HH676S B.00. Student guide"

Transcription

1 Quick Introduction to Java Servlets/NSJSP in the NonStop Environment Student guide

2 Contents Module 0 - Course Overview Course Objectives... Overview-2 Pathway The Way It Has Been... Overview-3 Pathway Application The Way It Has Been... Overview-4 Web-Enabling the Application... Overview-5 Java Servlet Example JDBC Version... Overview-6 Java Servlet Example Jpathsend Version... Overview-7 Attendee Take-Aways... Overview-8 Course Pre-Requisites... Overview-9 Class Schedule... Overview-10 Module 1 - NSJSP Overview Objectives Major Design Goals For NonStop Systems Nonstop System Layered Environment Itp Webserver Architecture NonStop Servlets For Java Server Pages (NSJSP) NSJSP Features Servlets Server Class NSJSP Product Directory Directory And Configuration Overview Configuring The Servlets Server Class Example Application Directory Structure Deployment Create War File (Step 1 of 2) Deployment Use NSJSP Manager (Step 2 of 2) NSJSP Manager NSJSP Manager Deployment NSJSP Manager Application Deployed NSJSP Manager Applications Listing Executing The Application Module 2 - Basic Servlet APIs Objectives Lifecyle Of A Servlet What Is Http? Http Request Methods Overview Http Basics Get And Post Methods Lifecycle Methods A Simulated Http Dialog Example Contents 1

3 Quick Introduction to Java Servlets/NSJSP in the NonStop Environment Class Participation: Invoke Servlet Reference To A Servlet: Url Format Deployment File: Web.Xml Example: Overview Of Servlet Code Example: Servlet Code Summary of Basic Servlet Structure Url And Web.Xml Relationship Revisited Miscellaneous Servlet Settings References Module 3 - Plain Old Java Object With NSJSP Objectives The Scenario Browser Based Front End Servlet Code Resource Descriptor File Web.Xml Development Steps Deployment Using NSJSP Manager Execute The Application Servlet Metrics Module 4 - Accessing SQL With JDBC Objectives What Is JDBC? JDBC Java Database Connectivity JDBC Versions Java.SQL Package JDBC API Capabilities Types Of JDBC Drivers Loading A Driver JDBC Drivermanager Interface Relationships JDBC Code Initialization JDBC Code Execute The Query The Complete Picture Code Example Prepared Statement Summary Additional Resources Contents 2

4 Contents Module 5 - Java Transactions Objectives Transactions In Java Introduction JDBC Transactions Connection Interface JDBC Code Non-Autocommit JTS-JTA Transactions Java Transaction API (JTA) JTA Code Example JTA Transaction Using Corba Transactions Using JDBC/MX Module 6 - Pathsend API For Java Objectives Pathsend API For Java Tsmpserver Class Data Conversions For Request/Reply Messages What Is Ddl2java? Ddl2java Outputs Ddl2java Tool Ddl2java Environment Sample Run Sample Ddl2java Output Jpathsend Using Jpathsend Java Servlet Code Example: Request/Reply Logic Contents 3

5 QUICK INTRODUCTION TO JAVA SERVLETS/NSJSP IN THE NONSTOP ENVIRONMENT Course Overview Copyright 2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.

6 COURSE OBJECTIVES Provide overview of NonStop Servlets for JavaServer Pages (NSJSP) Describe the basics of Java Servlets, including: Servlet life cycle Related APIs Use the Apache Tomcat container to: Code, compile, deploy and execute Java servlets in the NSJSP environment Use jdbc to access SQL/MP and SQL/MX tables Use jpathsend to access existing Pathway server classes 0 2

7 PATHWAY THE WAY IT HAS BEEN TS/MP TCP PATHMON Application PATHCTL TCP Application SCREEN COBOL Pseudo-Object Code PATHCTL Database SQL/MP or SQL/MX or Enscribe 0 3 Issue: How can the server classes be accessed from the web?

8 PATHWAY APPLICATION THE WAY IT HAS BEEN 0 4

9 WEB-ENABLING THE APPLICATION TS/MP NSJSP PATHMON HTTPD Servlet Server Class (SSC) Distributor Java Virtual Machine (JVM) Servlet Program TS/MP PATHMON Application PATHCTL Database Internet Browser TCP Application SCREEN COBOL SQL/MP or SQL/MX or Enscribe Pseudo-Object Code 0 5

10 JAVA SERVLET EXAMPLE JDBC VERSION 0 6

11 JAVA SERVLET EXAMPLE JPATHSEND VERSION 0 7

12 ATTENDEE TAKE-AWAYS Can leverage Java capabilities on NonStop to modernize their apps, starting with simple things like green screen modernization. Leverage Java with standards-based development, without need to rip and replace. No loss of NonStop fundamentals such as: Continuous availability Scalability Performance Transaction Control and Data Integrity Understand that NonStop will be a willing partner to assist customers with their application modernization efforts. 0 8

13 COURSE PRE-REQUISITES Basic understanding of Pathway/TS product Have a working knowledge of either Java and related technologies Familiar with OO concepts and basic terminology Basic understanding of html statements and tags Ability to work within NonStop OSS environment, in lieu of attendance of either of these courses: OSS for Unix Application Programmers OSS for Guardian Developers Note: This is not the venue to learn Java or SQL programming. 0 9

14 CLASS SCHEDULE Morning Session Module 1 NSJSP Overview Module 2 Basic Servlet APIs Module 3 Plain Old Java with NSJSP Afternoon Session Module 4 Accessing SQL with JDBC Module 5 Java Transactions Module 6 Pathsend API for Java 0 10

15

16 NSJSP OVERVIEW Module 1 Copyright 2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.

17 OBJECTIVES Describe basic HP NonStop system principles Describe the HP NonStop Transaction Services/MP (TS/MP) environment Explain the relationship between the TS/MP and itp WebServer environments Describe the architecture of NonStop Java Server Pages (NSJSP) Deploy Java Servlet functionality into a NSJSP instance 1 2

18 MAJOR DESIGN GOALS FOR NONSTOP SYSTEMS Fault tolerance and continuous availability Scalability Data integrity Data distribution Open access Client/server support Performance through parallelism Security 1 3

19 NONSTOP SYSTEM LAYERED ENVIRONMENT itp WebServer and NSJSP TS/MP OSS and Guardian Environments NonStop Operating System 1 4

20 ITP WEBSERVER ARCHITECTURE TS/MP PATHMON PATHCTL Internet HTTPD Generic-CGI Pathway-CGI PATHCTL Database Browser 1 5

21 NONSTOP SERVLETS FOR JAVA SERVER PAGES (NSJSP) Is a container that runs platform-independent Java Servlets and JavaServer Pages These provide dynamic content from a web server to a client browser over the HTTP protocol. NSJSP 6.0 (Product number T1222) Is based on the Tomcat version Runs with the itp Secure WebServer 6.0 Implements the Java Servlet 2.5 and the JavaServer Pages 2.1specifications. 1 6

22 NSJSP FEATURES A platform to host applications developed using the Java Open Source frameworks, including: MyFaces - An Apache implementation of JavaServer Faces (JSF) Apache Axis2 - An open source web services engine and framework. Spring - A Plain Old Java object (POJO) oriented application framework for development and deployment of Java applications. For more information, visit Hibernate - A popular (Object Relational Mapping) ORM solution for database access. Database access through JDBC drivers for NonStop SQL/MP and SQL/MX. Additional APIs, such as, the Pathsend and Pathway APIs implemented in the JToolkit, which can be used in web applications that are deployed in NSJSP. Green screen modernization and new web-based user interfaces Access to existing Pathway servers 1 7

23 SERVLETS SERVER CLASS TS/MP PATHMON PATHCTL Internet HTTPD Generic-CGI Pathway-CGI PATHCTL Database SERVLETS Browser 1 8

24 NSJSP PRODUCT DIRECTORY T1222PAX COPYOSS Guardian Environment /webserver /usr/tandem /nsjsp OSS Environment... /conf... /servlets... /bin /conf /logs... /webapps /T1222Hnn_<date>_BASE_Vnn /bin /conf /lib /logs /setup /webapps

25 DIRECTORY AND CONFIGURATION OVERVIEW /usr/tandem/webserver* * Class uses /usr/itpws /bin /conf /servlets servlet.config The sample directory ROOT shows the standard directory structure for an application /webapps /ROOT index.html /WEB-INF web.xml /conf... jdbc.config nsjsp-users.xml server.xml servlet.config web.xml... + Obsoleted 1 10

26 CONFIGURING THE SERVLETS SERVER CLASS (1 OF 2) # # Set the default value of the User ClassPath blank # set USRCP "" set USRCP $root/samples/servlets set USRCP $USRCP:/usr/tandem/javaexth10/lib/tdmext.jar set JAVAEXT /usr/tandem/javaexth10/lib set JDBCMP /usr/tandem/jdbcmp/current/lib... # append USRCP ":<Custom-ClassPath>": append USRCP :/usr/tandem/javaexth10/lib/tdmext.jar servlet. config 1 11

27 4 5 6 CONFIGURING THE SERVLETS SERVER CLASS (2 OF 2)... Server $server_objectcode { CWD $env(nsjsp_home) Env CLASSPATH=$JVCP:$USRCP Env JAVA_HOME=$env(JAVA_HOME) Env JREHOME=$env(JAVA_HOME)/jre Env _RLD_LIB_PATH=$NSJSP_DLL_PATH:$JAVAEXT:$JDBCMP Env TANDEM_FILEMAPS_CONFIG=$root/conf/filemaps.config Env BANK_CATALOG=$SERVLET_BANK MapDefine =TCPIP^PROCESS^NAME $transport MapDefine =PARTS /G/fc1/sales/parts MapDefine =PARTSUPP /G/fc1/invent/partsupp... # # This is the actual Arglist used to start up the NSJSP Container. # Arglist -Xmx64m -Xss128k -Xnoclassgc \ -Djdbc.drivers=com.tandem.sqlmp.SQLMPDriver \ servlet. config 1 12

28 itp WebServer specific webapps app-name WEB-INF jsp images index.html classes Byte code lib Jar files web.xml jsp code image files Source code 1 13

29 EXAMPLE APPLICATION DIRECTORY STRUCTURE /home/itp66/mgr/lab/servlets/webapps/liew: ls -R. META-INF WEB-INF images index.html partps.jsp./meta-inf: MANIFEST.MF./WEB-INF: classes web.xml./web-inf/classes: ddlsrc partsql.class partsrc partclass partsql.java./web-inf/classes/partclass: I_Parts_maint_rpl.class O_Parts_maint_req.class O_Parts_list_req.class./WEB-INF/classes/partsrc: I_Parts_maint_rpl.java O_Parts_list_req.java O_Parts_maint_req.java./images: tomcat.gif 1 14

30 DEPLOYMENT CREATE WAR FILE (STEP 1OF 2) Create the web archive file (war file) /home/itp66/liew auto [1]>ls META-INF WEB-INF images index.html partps.jsp /home/itp66/liew auto [2]>jar -cvf liew.war. added manifest ignoring entry META-INF/ ignoring entry META-INF/MANIFEST.MF adding: WEB-INF/(in = 0) (out= 0)(stored 0%) adding: WEB-INF/classes/(in = 0) (out= 0)(stored 0%) adding: WEB-INF/classes/ddlsrc(in = 116) (out= 57)(deflated 50%) adding: WEB-INF/classes/partclass/(in = 0) (out= 0)(stored 0%) adding: WEB-INF/classes/partclass/I_Parts_maint_rpl.class(in = 8269) (out= 3314)(deflated 59%).... adding: images/tomcat.gif(in = 1934) (out= 1939)(deflated 0%) adding: index.html(in = 1981) (out= 906)(deflated 54%) adding: partps.jsp(in = 17334) (out= 3708)(deflated 78%) /home/itp66/liew auto [334]>ls META-INF images liew.war WEB-INF index.html partps.jsp Note: The war file will be exploded at deployment only if the parameter unpackwars found in /servlets/conf/server.xml is set to true. 1 15

31 DEPLOYMENT USE NSJSP MANAGER (STEP 2 OF 2) Web applications can be deployed using the NSJSP Manager Class example:

32 NSJSP MANAGER Set the scope and then click on Deployment tab 1 17

33 NSJSP MANAGER DEPLOYMENT Specify the context name and the location of the war file and click Deploy. 1 18

34 NSJSP MANAGER APPLICATION DEPLOYED Status shows successful deployment; click on Applications tab. 1 19

35 NSJSP MANAGER APPLICATIONS LISTING Note the context name that should be used to access the application 1 20

36 EXECUTING THE APPLICATION 1 21

37

38 BASIC SERVLET APIs Module 2 Copyright 2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.

39 OBJECTIVES Describe the lifecycle of a Servlet Briefly describe what is HTTP protocol Describe the meaning and use of GET/POST methods Describe some basic Servlet APIs Examine a sample Servlet source code 2 2 Date or Rev #

40 LIFECYLE OF A SERVLET Simple object-oriented design Constructed and initialized Services zero or more requests till service shuts down Then Servlet is destroyed Garbage collection occurs, hopefully Loaded once and remains memory resident while servicing requests HTML Form Data HTML Data Internet HP NonStop Server (NSJSP) HttpServlet service: dodelete() doget() dooptional() dopost doput dotrace() 2 3 Date or Rev #

41 WHAT IS HTTP? Hypertext Transfer Protocol (HTTP) is a communications protocol. Is a request/response standard between client/server web based applications. Requested resource is indicated by Uniform Resource Locator (URL). Server responds with HTML pages, graphic images, sound, video, and other multimedia files. 2 4 Date or Rev #

42 HTTP REQUEST METHODS OVERVIEW Eight methods are available to indicate the desired action to be performed on an identified resource. Commonly used methods are: GET POST Other methods are: HEAD PUT DELETE TRACE OPTIONS 2 5 Date or Rev #

43 HTTP BASICS GET AND POST METHODS (1 OF 2) GET Method: Used to retrieve information from a specified URI. Request is in the form of parameters encoded in the URI (known as a Query String). Should not be used for requests that transfer large volumes of data to the webserver. Is assumed to be a safe, repeatable operation by browsers, caches and other HTTP aware components. Operation must have no side effects and GET requests can be re-issued without concern over the consequences. This is a safe and repeatable operation. 2 6 Date or Rev #

44 HTTP BASICS GET AND POST METHODS (2 OF 2) POST Method: Used for operations that have side effects and cannot be safely repeated. Request message has a content body that is normally used to send parameters and data. Technically no limit on volume of data submitted. Must be used if files or other variable length data is sent to the webserver. Modifying the quantity in the shopping cart affects the total cost. 2 7 Date or Rev #

45 LIFECYCLE METHODS init() public void init (ServletConfig config) throws ServletException; Invoked immediately after a Servlet is instantiated (only once) Creates and initializes needed resource service() public void service (ServletRequest req, ServletResponse res) throws ServletException, IOException; Processes requests from clients Supports http requests Determines request type and calls appropriate method Most common implementation is the HttpServlet class destroy () public void destroy (); Terminates life of Servlet, and resources are released 2 8 Date or Rev #

46 A SIMULATED HTTP DIALOG EXAMPLE $FC1 LIEW 1> telnet TELNET Client - T9558H01 - (10MAY07) - (IPMAAG) Copyright Tandem Computers Incorporated 2004 \venus.$system.sys20.telnet>open Trying...Connected to Escape character is '^]'. GET / HTTP/1.0 # Push Enter key Host: # Push Enter key HTTP/ OK Date: Sat, 11 Sep :35:34 GMT Server: itp Secure WebServer/7.0(Global) MIME-version: 1.0 Last-modified: Sun, 27 Dec :16:46 GMT Connection: close Content-type: text/html <TITLE>Index of /</TITLE><H1>Index of /</H1> <PRE> Name Last Modified Size <HR> <A HREF="..">../</A> 04-Dec-09 14:33 <A HREF="NSMweb">NSMweb/</A> 04-Dec-09 15:17 <A HREF="index.sample.html">index.sample.html</A> 04-Dec-09 14:33 4K Connection closed. Connection closed by foreign host. 2 9 Date or Rev #

47 CLASS PARTICIPATION: INVOKE SERVLET URL is The servlet counts and displays how many times it has been invoked. The same instance variable (count) exists between invocations and for all invocations of the same servlet process in a Pathway server class. >PATHCOM $ZWEB = INFO SERVLETS SERVER SERVLETS PROCESSTYPE OSS... MAXLINKS 8 MAXSERVERS 4 NUMSTATIC 4... =status servlets,detail SERVER #RUNNING ERROR INFO SERVLETS 4 PROCESS STATE ERROR INFO #LINKS WEIGHT $Z1ZN RUNNING 1 3 $Z1ZP RUNNING 1 3 $Z1ZQ RUNNING 1 3 $Z1ZR RUNNING Date or Rev #

48 REFERENCE TO A SERVLET: URL FORMAT Page URL is: <servlet> <servlet-name>initcounter</servlet-name> <servlet-class>initcounter</servlet-class> </servlet> <servlet-mapping> <servlet-name>initcounter</servlet-name> <url-pattern>/initcounter</url-pattern> </servlet-mapping> 2 11 Date or Rev #

49 DEPLOYMENT FILE: web.xml <?xml version="1.0" encoding="iso "?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" " <web-app> <servlet> <servlet-name>initcounter</servlet-name> <servlet-class>initcounter</servlet-class> </servlet> <servlet-mapping> <servlet-name>initcounter</servlet-name> <url-pattern>/initcounter</url-pattern> </servlet-mapping> </web-app> 2 12 Date or Rev #

50 EXAMPLE: OVERVIEW OF SERVLET CODE import... public class InitDestroyCounter extends HttpServlet { int count; String Pname; public void init (ServletConfig config) throws ServletException { // Initialization of count, and retrieve process name. } // end init public void doget (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // Build html formatted text to be returned to client. } // end doget public void destroy () { savestate(); } // end doget public void savestate() { // Try to save the accumulated count and write to file. } // end savestate } // end class 2 13 Date or Rev #

51 EXAMPLE: SERVLET CODE (1 OF 2) import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class InitCounter extends HttpServlet { int count; public void init(servletconfig config) throws ServletException { super.init(config); String initial = config.getinitparameter("initial"); try { count = Integer.parseInt(initial); } catch (NumberFormatException e) { count = 0; } } 2 14 Date or Rev #

52 EXAMPLE: SERVLET CODE (2 OF 2) public void doget(httpservletrequest req, HttpServletResponse res) throws ServletException, IOException { res.setcontenttype("text/plain"); PrintWriter out = res.getwriter(); count++; out.println("since loading (and with a possible initialization"); out.println("parameter figured in), this servlet has been accessed"); out.println(count + " times."); } } 2 15 Date or Rev #

53 SUMMARY OF BASIC SERVLET STRUCTURE Servlets must extend the HttpServlet class and import these packages: javax.servlet javax.servlet.http java.io The doget method overrides the doget method of the HttpServlet class and processes all HTTP requests that use the Get method. The dopost method overrides the dopost method of the HttpServlet class and processes all HTTP requests that use the Post method. The setcontenttype method of the response object sets the content type of the response that is returned to the browser. The getwriter method of the response object returns a PrintWriter object which is used to send HTML statements to the browser Date or Rev #

54 URL AND web.xml RELATIONSHIP REVISITED <?xml version="1.0" encoding="iso "?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN " <web-app> <servlet> 4 3 <servlet-name>aservlet</servlet-name> <servlet-class>partsql</servlet-class> </servlet> <servlet-mapping> <servlet-name>aservlet</servlet-name> <url-pattern>/partsql</url-pattern> </servlet-mapping> These are tags to match 2 the servlet with the mapping. 3 The URL pattern indicates how the servlet can be addressed. 4 This specifies the class file name. </web-app> Format of URLs: /servlets/partsql 2 17 Date or Rev #

55 MISCELLANEOUS SERVLET SETTINGS For access to JToolkit, Pathway TS/MP and TMF, edit: /<Web-Server-Install Dir/servlets/conf/servlet.config and include these: set USRCP $root/samples/servlets: /usr/tandem/javaexth10/lib/tdmext.jar Env _RLD_LIB_PATH=$NSJSP_DLL_PATH: /usr/tandem/javaexth10/lib 2 18 Date or Rev #

56 REFERENCES Tutorials and Examples on the Internet: Books: Core Servlets and JavaServer Pages (Second Edition) Volume 1: Core Technologies by Marty Hall and Larry Brown Head First Servlets and JSP, Second Edition by Bryan Basham, Kathy Sierra, Bert Bates Java Servlet Programming, Second Edition by Jason Hunter Murach's Java Servlets and JSP (2nd Edition) by Joel Murach and Andrea Steelman Pure JSP: Java erver Pages by James Goodwill 2 19 Date or Rev #

57

58 PLAIN OLD JAVA OBJECT WITH NSJSP Module 3 Copyright 2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.

59 OBJECTIVES Examine a browser based user interface to communicate with a servlet executing in the NSJSP environment The user will be prompted for his/her first name and last name. Create a servlet that returns a simple greeting for the name entered. Deploy the servlet in the NSJSP environment Examine the run time metrics maintained by NSJSP for the servlet 3 2

60 THE SCENARIO NSJSP Environment TS/MP PATHMON HTTPD SERVLETS First Name: Last Name: WEB URL: Response format: Servlet GreetingServlet at /servlets/greeting Welcome fname lname Key config and source files: index.html web.xml GreetingServlet.java 3 3

61 BROWSER BASED FRONT END Prompt the user for his/her first name and last name Submit the entry to a servlet to create a greeting for that name Display the greeting returned index.html <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso "> <title>insert title here</title> </head> <body> <form action="greetingservlet" method="post"> First Name: <input type="text" name="firstname" size="20"><br> Last Name: <input type="text" name="lastname" size="20"> <br><br> <input type="submit" value="submit"> </form> </body> 3 4

62 SERVLET CODE public class GreetingServlet extends HttpServlet { }... protected void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { } response.setcontenttype("text/html;charset=utf-8"); PrintWriter out = response.getwriter(); String firstname = request.getparameter("firstname").tostring(); String lastname = request.getparameter("lastname").tostring(); out.println("<html>"); out.println("<head>"); out.println("<title>servlet GreetingServlet</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>servlet GreetingServlet at " + request.getcontextpath () + "</h1>"); out.println("<p>welcome " + firstname + " " + lastname + "</p>"); out.println("</body>"); out.println("</html>"); out.close(); 3 5

63 RESOURCE DESCRIPTOR FILE web.xml <servlet> <description> </description> <display-name> GreetingServlet</display-name> <servlet-name>greetingservlet</servlet-name> <servlet-class> com.hp.servlet.greetingservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>greetingservlet</servlet-name> <url-pattern>/greetingservlet</url-pattern> </servlet-mapping> 3 6

64 DEVELOPMENT STEPS Create the home page ie. index.html Create relevant servlet source code and compile using javac ECLIPSE is a good choice of an environment to build and deploy onto NonStop server Create the resource descriptor file named web.xml Rarely need to create from scratch Leverage existing sources ANT (accessible from ECLIPSE) is a useful tool Use jar to create a war file $ jar -cvf MyDemo.war. Deploy using NSJSP Manager 3 7

65 DEPLOYMENT USING NSJSP MANAGER 3 8

66 EXECUTE THE APPLICATION 3 9

67 SERVLET METRICS (1OF 7) 3 10

68 SERVLET METRICS (2 OF 7) 3 11

69 SERVLET METRICS (3 OF 7) 3 12

70 SERVLET METRICS (4 OF 7) 3 13

71 SERVLET METRICS (5 OF 7) 3 14

72 SERVLET METRICS (6 OF 7) 3 15

73 SERVLET METRICS (7 OF 7) 3 16

74

75 ACCESSING SQL WITH JDBC Module 4 Copyright 2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.

76 OBJECTIVES Describe JDBC Describe the contents of the java.sql package Describe JDBC API capabilities Examine usage of some JDBC interfaces and their methods Examine code that accesses an HP NonStop SQL/MX table 4 2 Date or Rev #

77 WHAT IS JDBC? JDBC is an API that lets you access virtually any tabular data source from the Java Language applet Client EJB JNDI JDBC servlet JTA JSP JTS Application Server DBMS Database 4 3 Date or Rev #

78 JDBC JAVA DATABASE CONNECTIVITY Statement stmt = ConnSQLMX.createStatement(); ResultSet res = stmt.executequery(sqlmxquery); while (res.next()) { System.out.println ("Custnum: " + res.getint(1) + " Custname is: " + res.getstring(2)); } // end while JDBC provides database access to Java There are two distinct parts to JDBC Java classes standard SQL query text standard + extensions Transaction models Auto commit, manual commit, transaction aware Driver types for NonStop SQL Main support is Type 2 Also have Type 3 for development 4 4 Date or Rev #

79 JDBC VERSIONS Currently at JDBC 3.0 for SQL/MX Two versions Transaction unaware database transactions Transaction aware use JTA or TMF.Current Also JDBC server to support Type 3 driver JDBC 3.0 driver for SQL/MX release Date or Rev #

80 JAVA.SQL PACKAGE Includes APIs for: Making a connection with a data source Sending SQL statements to a database Retrieving and updating the results of a query Mapping an SQL value to the standard mapping in the Java programming language Throwing exceptions 4 6 Date or Rev #

81 JDBC API CAPABILITIES // Load JDBC/MX driver Class.forName ("com.tandem.sqlmx.sqlmxdriver"); // Create a JDBC connection Connection ConnSQLMX = DriverManager.getConnection ("jdbc:sqlmx:"); // Create the SQL select statement Statement stmt = ConnSQLMX.createStatement(); // Submit the query and create a ResultSet object: ResultSet res = stmt.executequery(sqlmxquery); // Show results from the query: while (res.next()) { // Use get* methods that correspond to the columns: System.out.println ("Custnum: " + res.getint(1) + " Custname is: " + res.getstring(2)); } // end while 4 7 Date or Rev #

82 TYPES OF JDBC DRIVERS Type 1 driver JDBC-ODBC bridge, possibly written in Java Type 2 driver Native-API, partly Java technology enabled driver Type 3 driver Net-protocol, fully Java technology enabled driver Type 4 driver Native-protocol, fully Java technology enabled driver 4 8 Date or Rev #

83 LOADING A DRIVER Client invokes Java program on Server JVM JDBC Code Type 2 Driver JVM executing JDBC code on Client NonStop JDBC Server Type 2 Driver SQL/MX Type 3 Driver 4 9 Date or Rev #

84 JDBC DRIVERMANAGER JDBC DriverManager maintains a list of available JDBC drivers. // Load JDBC/MX driver Class.forName ("com.tandem.sqlmx.sqlmxdriver"); // Create a JDBC connection Connection ConnSQLMX = DriverManager.getConnection ("jdbc:sqlmx:"); 4 10 Date or Rev #

85 INTERFACE RELATIONSHIPS DriverManager Statement executequery ResultSet getconnection createstatement executeupdate Connection Extract Data getxxx( ) preparestatement Driver executequery PreparedStatement executeupdate Database 4 11 Date or Rev # Data Types: XXX := Int String Long... Set Input Data setxxx( ) Number of rows affected

86 JDBC CODE INITIALIZATION import java.sql.*; public class Select { public static void main (String args[]) { String sqlmxquery ="select custnum, custname from =cust"; try { // Load JDBC/MX driver Class.forName ("com.tandem.sqlmx.sqlmxdriver"); } // Create a JDBC connection Connection ConnSQLMX = DriverManager.getConnection ("jdbc:sqlmx:"); } catch (Exception e) { System.err.println ("SQL/MX Exception: " + e.getmessage()); } } // end main 4 12 Date or Rev #

87 JDBC CODE EXECUTE THE QUERY // Create the SQL select statement Statement stmt = ConnSQLMX.createStatement(); // Submit the query and create a ResultSet object: ResultSet res = stmt.executequery(sqlmxquery); // Show results from the query: while (res.next()) { // Use get* methods that correspond to the columns: System.out.println ("Custnum: " + res.getint("custnum") + " Custname is: " + res.getstring(2)); } // end while res.close(); stmt.close(); ConnSQLMX.close(); 4 13 Date or Rev #

88 THE COMPLETE PICTURE 4 14 import Termin.*; import java.sql.*; public class Select { public static void main (String args[]) { String sqlmxquery ="select custnum, custname from =cust"; try { // Load JDBC/MX driver Class.forName ("com.tandem.sqlmx.sqlmxdriver"); // Create a JDBC connection Connection ConnSQLMX = DriverManager.getConnection ("jdbc:sqlmx:"); // Create the SQL select statement Statement stmt = ConnSQLMX.createStatement(); // Submit the query and create a ResultSet object: ResultSet res = stmt.executequery(sqlmxquery); // Show results from the query: while (res.next()) { // Use get* methods that correspond to the columns: System.out.println ("Custnum: " + res.getint("custnum") + " Custname is: " + res.getstring(2)); } // end while } catch (Exception e) { System.err.println ("SQL/MX Exception: " + e.getmessage()); } } // end main } Date or Rev #

89 CODE EXAMPLE PREPARED STATEMENT (1 OF 2) // Create a dynamic SQL statement for insert String updatestmt = "update =cust set custname =? where custnum=?"; // Create the Prepared Statement PreparedStatement ps = ConnSQLMX.prepareStatement (updatestmt); // Update a row into SQL/MX table short Cust_num = (short) Termin.inInt ("Enter customer number: "); ps.setint (2, Cust_num ); String Cust_name = Termin.inString ("Enter new customer name: "); ps.setstring (1, Cust_name); 4 15 Date or Rev #

90 CODE EXAMPLE PREPARED STATEMENT (2 OF 2) //Execute SQL statement int row_cnt = ps.executeupdate (); if (row_cnt == 0) System.err.println ("Row not updated "); else if (row_cnt == 1) System.out.println ("Row is updated for customer #: " + Cust_num); else System.err.println ( Uh Oh, what is wrong?"); 4 16 Date or Rev #

91 SUMMARY Class.forName ("com.tandem.sqlmx.sqlmxdriver"); Connection ConnSQLMX = DriverManager.getConnection ("jdbc:sqlmx:"); String sqlmxquery ="select custnum, custname from =cust"; Statement stmt = ConnSQLMX.createStatement(); ResultSet res = stmt.executequery(sqlmxquery); while (res.next()) { // Use get* methods that correspond to the columns:... } // end while String updatestmt="update =cust set custname =? Where... ; PreparedStatement ps = ConnSQLMX.prepareStatement (updatestmt); ps.setstring (1, Cust_name); int row_cnt = ps.executeupdate (); 4 17 Date or Rev #

92 ADDITIONAL RESOURCES Manual available in NonStop Technical Library (NTL): NonStop Server for Java Programmer's Reference Book: JDBC(TM) API Tutorial and Reference: Universal Data Access for the Java(TM) 2 Platform (2nd Edition) by S. White, M. Fisher, R. Cattell, G. Hamilton, and M. Hapner Web: Date or Rev #

93

94 JAVA TRANSACTIONS Module 5 Copyright 2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.

95 OBJECTIVES Describe the use of JDBC to define transactions in Java Autocommit mode Non-autocommit mode Write Java code to control JDBC-based transactions Describe the use of JTS and JTA to define transactions in Java Write Java code to control JTA-based transactions Describe support for transactions using JDBC/MX 5 2

96 TRANSACTIONS IN JAVA INTRODUCTION Two primary ways to define and control transactions JDBC Transactions Controlled through HP NonStop SQL/MP JTS-JTA Transactions Controlled through explicit API calls 5 3

97 JDBC TRANSACTIONS JDBC transactions use the standard JDBC Driver: jdbc:sqlmp: Auto-commit mode: By default, each SQL/MP statement is wrapped by a unique transaction. Driver executes begin transaction before executing each SQL/MP statement Driver commits transaction before executing another SQL/MP statement Non-autocommit mode: Driver executes begin transaction before executing the first SQL/MP statement Multiple SQL/MP statements may be executed Programmer must explicitly execute commit transaction or rollback transaction 5 4

98 CONNECTION INTERFACE public abstract interface Connection { public abstract void createstatement() throws SQLException; public abstract void preparestatement(string sql) throws SQLException; } Transaction Methods: public abstract void commit()throws SQLException; public abstract void rollback()throws SQLException; public abstract void setautocommit(boolean autocommit) throws SQLException;

99 JDBC CODE NON-AUTOCOMMIT import java.sql.* public class Example extends HttpServlet { Connection con; ResultSet rslt; PreparedStatement ps; private void MultUpdate () throws IOException { try { // Prepare the SQL statements here // con.setautocommit(false); // Execute multiple SQL statements ps.executeupdate(); ps.executeupdate(); con.commit(); } catch (Exception e) { con.rollback(); } con.setautocommit(true); } Turn off autocommit Complete transaction explicitly 5 6

100 JTS-JTA TRANSACTIONS Java Transaction Services (JTS) Java implementation of CORBA OTS Detailed API for low-level developers Java Transaction API (JTA) Simpler API for application development 5 7

101 JAVA TRANSACTION API (JTA) public interface javax.transaction.usertransaction { public abstract void begin() throws IllegalStateException, SystemException; public abstract void commit() throws IllegalStateException, SystemException, TransactionRolledBackException, HeuristicRollbackException, HeuristicMixedException; public abstract int getstatus() throws SystemException; public abstract void rollback() throws IllegalStateException, SecurityException, SystemException; public abstract void setrollbackonly() throws IllegalStateException, SystemException; public abstract void settransactiontimeout(int seconds) throws SystemException; } 5 8

102 JTA CODE EXAMPLE import javax.transaction.usertransaction; import com.tandem.jta.jtafactory; public class JTAExample extends HttpServlet { // private void MultUpdate () throws IOException { UserTransaction utx = JTAFactory.getUserTransaction(); try { utx.begin(); // // Execute multiple database updates // Create UserTransaction object if (allok) { utx.commit(); } else { utx.rollback(); } } catch (Exception e) { utx.rollback(); } // } } Complete transaction explicitly 5 9

103 JTA TRANSACTION USING CORBA UserTransaction utx = JTAFactory.getUserTransaction(JTS); try { utx.begin(); // // Execute multiple database updates // possibly on multiple systems

104 TRANSACTIONS USING JDBC/MX public class example extends HttpServlet { public void init(servletconfig config) throws ServletException { } try { String url = "jdbc:sqlmx:"; con = DriverManager.getConnection(url); } catch (Exception e) { System.out.println("init method failed; msg = " + e.getmessage()); return; } 5 11

105

106 PATHSEND API FOR JAVA Module 6 Copyright 2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.

107 OBJECTIVES Explain the JPathsend facility for communicating with Pathway server classes Describe the major classes of the API and their usages Describe the usage of the ddl2java utility Show some examples of API sending messages to and receiving messages from a Pathway server class 6 2

108 PATHSEND API FOR JAVA Provides support for a Java client to communicate with Pathway servers written in Java, HP C, or HP COBOL Major classes are: TsmpServer This class represents a communication session with a specific server class within a specific Pathway application. TsmpServerRequest, TsmpServerReply and TsmpGenericServerReply classes are no longer recommended to use. Contained in com.tandem.tsmp package of tdmext.jar file 6 3

109 TSMPSERVER CLASS (1 OF 2) Represents a session with a specific server class within a specific Pathway application Class constructor takes Pathmon name and server class name as its parameters There are four overloaded service methods that send out a request to the server and receive a reply back if successful. int service(byte[] request, int requestlen, byte[] reply) int service(guardianoutput request, byte[] reply) int service(guardianoutput request, GuardianInput reply) void service(tsmpserverrequest request, TsmpServerReply reply) This method is deprecated as of T2716V10 and is replaced by the first three service methods. The return int value gives the actual number of bytes in the server reply 6 4

110 TSMPSERVER CLASS (2 OF 2) GuardianOutput data type is converted to byte [] for request and byte [] data type is converted to GuardianInput for reply automatically if the conversion is not manually done. IllegalArgumentException, DataConversionException, TsmpserverException, TsmpServerUnabailableException, TsmpSendException, TsmpRequestException or TsmpReplyException may be thrown. 6 5

111 DATA CONVERSIONS FOR REQUEST/REPLY MESSAGES Requester IPC-REQUEST IPC-REPLY Server Legacy: no conversion is needed Byte [] O_Ipc_rqst I_Ipc_rqst Client I_Ipc_rply Byte [] O_Ipc_rply Server 6 6 Java API with ddl2java generated classes: conversion is automatic

112 WHAT IS DDL2JAVA? A key component for accessing HP NonStop Server applications with the Java language A command-line tool that generates from a Data Definition Language (DDL) dictionary GuardianOutput classes can represent a requester s request message to a server GuardianInput classes can represent a server s reply message to a requester Optionally compiles the generated Java class source files Supports Java, C, and COBOL Is an element of the JToolkit product Supports Enscribe API for Java, Pathsend API for Java, and Pathway API for Java 6 7

113 DDL2JAVA OUTPUTS The ddl2java tool creates a class that implements the GuardianInput interface for messages that are input to a Java application. A getxxx helper method is generated for each field in the message structure. The unmarshal method of GuardianInput converts byte array data into individual Java member fields. The ddl2java tool creates a class that implements the GuardianOutput interface for messages that are output from a Java application. setxxx and clearxxx helper methods are generated for each field in the message structure. The marshal method of GuardianOutput formats Java member fields into a byte array. 6 8

114 DDL2JAVA TOOL DDL Dictionary DDL DDL Dictionary Dictionary Guardian Environment OSS Environment ddl2java Import Generated Classes Servlet Source.java Compile.class Servlet Byte Codes 6 9

115 DDL2JAVA ENVIRONMENT DDL Dictionary DDL source def partreq 02 code binary partno pic 9(4). 02 desc pic x(18). 02 price pic 9999v qty pic 9(4). /G/volume/subvol item list def partreq,output,cobol,nn def partrpl,input,cobol,nn -dpath -i import <package name> public class I_Partrpl implements GuardianIntput { import <package name> public class O_Partreq implements GuardianOutput { ddl2java -d -c -p <package name>/ I_Partrpl.class <package name>/ O_Partreq.class 6 10 <source path>/ I_Partrpl.java <source path>/ O_Partreq.java

116 SAMPLE RUN DEF parts-maint-req. 02 ipm-header TYPE *. 02 parts-record. 03 partnum PIC 9(04). 03 partdesc PIC X(18). 03 price PIC S9(6)V99 COMP. 03 qty-available PIC S9(5) COMP. END DDL DDL elementary field names DEF parts-maint-req,output,cobol,nn Item list ddl2java dpath /G/data/sdbapp i itemlist p partclass d partsrc c 6 11

117 SAMPLE DDL2JAVA OUTPUT (1 OF 3) package partclass; import com.tandem.ext.guardian.*; import com.tandem.ext.util.*; public class O_Parts_maint_req implements com.tandem.ext.guardian.guardianoutput { protected int _bufferlen = 74; public short reply_code; public short trans_code; public String logon_id; public String tmf_abort_sw; Class name Package name GuardianOutput interface public String filler0; public String parts_record_partnum; public String parts_record_partdesc; public int parts_record_price; public int parts_record_qty_available; /** O_Parts_maint_req Constructor */ public O_Parts_maint_req() { } Java field members converted from DDL elementary field names 6 12

118 SAMPLE DDL2JAVA OUTPUT (2 OF 3) package partclass; public class O_Parts_maint_req implements com.tandem.ext.guardian.guardianoutput { set method for each converted Java field member /** Used to set a value for value the value to be set. */ public void setparts_record_partnum(string value) { parts_record_partnum = value; } public void setparts_record_partdesc(string value) { parts_record_partdesc = value; } public void setparts_record_price(int value) { parts_record_price = value; } public void setparts_record_qty_available(int value) { parts_record_qty_available = value; } 6 13

119 SAMPLE DDL2JAVA OUTPUT (3 OF 3) public byte[] marshal(byte [] _buffer) throws com.tandem.ext.util.dataconversionexception { if (_buffer.length < _bufferlen) throw new DataConversionException (DataConversionException.ConvError.RANGE, "Buffer length less than minimum required buffer length"); int _offset; _offset = 0; DataConversion.JavaShortToBIN16(_buffer,reply_code,_offset); _offset = 2; DataConversion.JavaShortToBIN16(_buffer,trans_code,_offset); _offset = 4; if(logon_id!= null) DataConversion.JavaStrToNumStr (_buffer,logon_id, _offset, 6, 0, 16); _offset = 10; if (tmf_abort_sw!= null) { 6 14

120 JPATHSEND TS/MP PATHMON Pathway Server Class HTTPD servlets JPathsend Database Java Virtual Machine (JVM) Servlet.class Generated Request/reply; TsmpServer Class 6 15

121 USING JPATHSEND 1. Use ddl2java to generate a O_<ipc_rqst>.class file for the request and a I_<ipc_rply>.class file for the reply. 2. Create instances of the request and reply buffers. 3. Create an instance of the TSMPServer specifying the PATHMON name and the Pathway server class name. 4. Use the set methods of the request class to set up the request buffer. 5. Use the service method of the TSMPServer class to send the request and obtain the reply. 6. Use the get methods of the reply class to obtain data from the reply buffer. 6 16

122 JAVA SERVLET CODE EXAMPLE: REQUEST/REPLY LOGIC (1 OF 2) private void addaction (HttpServletRequest req, ServletOutputStream out) throws IOException { try { // Create an instance of a JTA user transaction UserTransaction utx = JTAFactory.getUserTransaction(JTAFactory.TMF); try { utx.begin(); /* Begin a TMF transaction */ TsmpServer partsrvr = new TsmpServer(pmName,"srv-sdb206"); // Create instances of GuardianInput and GuardianOutput objects O_Parts_maint_req psreq = new O_Parts_maint_req(); I_Parts_maint_rpl psrpl = new I_Parts_maint_rpl(); // Set the request variables (Note all variables are Strings) psreq.setreply_code((short)2); psreq.settrans_code((short)1); psreq.setparts_record_partnum(partin); psreq.setparts_record_partdesc(descin); pricein = fixprice(pricein); psreq.setparts_record_price(integer.parseint(pricein)); psreq.setparts_record_qty_available(integer.parseint(qtyin)); // Invoke service method of TsmpServer class to do the Pathsend partsrvr.service(psreq,psrpl); // Return the column values from the Pathway server msg = psrpl.getterm_stat() + psrpl.getterm_stat_text(); utx.commit(); 6 17 }

123 JAVA SERVLET CODE EXAMPLE: REQUEST/REPLY LOGIC (2 OF 2) catch (Exception e) { // Errors from the inner "try" block are caught utx.rollback(); msg = e.getmessage() + "<br>"; } } catch (Exception e) { // Errors from the outer "try" block are caught msg = e.getmessage() + "<br>"; } return; } 6 18

124

125 Notice Copyright 2010 Hewlett-Packard Development Company, L.P. Microsoft, Windows, and Windows NT are U.S. registered trademarks of Microsoft Corporation. Intel is a trademark of Intel Corporation in the U.S. and other countries and is used under license. Java is a US trademark of Sun Microsystems, Inc. Pentium is a U.S. registered trademark of Intel Corp. UNIX is a registered trademark of The Open Group. All other product names mentioned herein may be trademarks of their respective companies. Export Requirements. You may not export or re-export products subject to this agreement in violation of any applicable laws or regulations. Without limiting the generality of the foregoing, products subject to this agreement may not be exported, reexported, otherwise transferred to or within (or to a national or resident of) countries under U.S. economic embargo and/or sanction including the following countries: Cuba, Iran, North Korea, Sudan and Syria. This list is subject to change. In addition, products subject to this agreement may not be exported, re-exported, or otherwise transferred to persons or entities listed on the U.S. Department of Commerce Denied Persons List; U.S. Department of Commerce Entity List (15 CFR 744, Supplement 4); U.S. Treasury Department Designated/Blocked Nationals exclusion list; or U.S. State Department Debarred Parties List; or to parties directly or indirectly involved in the development or production of nuclear, chemical, or biological weapons, missiles, rocket systems, or unmanned air vehicles as specified in the U.S. Export Administration Regulations (15 CFR 744); or to parties directly or indirectly involved in the financing, commission or support of terrorist activities. By accepting this agreement you confirm that you are not located in (or a national or resident of) any country under U.S. embargo or sanction; not identified on any U.S. Department of Commerce Denied Persons List, Entity List, US State Department Debarred Parties List or Treasury Department Designated Nationals exclusion list; not directly or indirectly involved in the development or production of nuclear, chemical, biological weapons, missiles, rocket systems, or unmanned air vehicles as specified in the U.S. Export Administration Regulations (15 CFR 744), and not directly or indirectly involved in the financing, commission or support of terrorist activities. Hewlett-Packard Company shall not be liable for technical or editorial errors or omissions contained herein. The information is provided as is without warranty of any kind and is subject to change without notice. The warranties for HP products are set forth in the express limited warranty statements accompanying such products. Nothing herein should be construed as constituting an additional warranty. This is an HP copyrighted work that may not be reproduced without the permission of HP. Printed in the US Quick Introduction to Java Servlets/NSJSP in the NonStop Environment Student Text Document History Edition Date Part Number Second First September 2010 July 2009 HH676S A.00

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1 Java Enterprise Edition Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1 Java Beans Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 2 Java Bean POJO class : private Attributes public

More information

Servlet Fudamentals. Celsina Bignoli

Servlet Fudamentals. Celsina Bignoli Servlet Fudamentals Celsina Bignoli bignolic@smccd.net What can you build with Servlets? Search Engines E-Commerce Applications Shopping Carts Product Catalogs Intranet Applications Groupware Applications:

More information

Session 8. Introduction to Servlets. Semester Project

Session 8. Introduction to Servlets. Semester Project Session 8 Introduction to Servlets 1 Semester Project Reverse engineer a version of the Oracle site You will be validating form fields with Ajax calls to a server You will use multiple formats for the

More information

Web based Applications, Tomcat and Servlets - Lab 3 -

Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems Web based Applications, - - CMPUT 391 Database Management Systems Department of Computing Science University of Alberta The Basic Web Server CMPUT 391 Database Management

More information

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http?

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http? What are Servlets? Servlets1 Fatemeh Abbasinejad abbasine@cs.ucdavis.edu A program that runs on a web server acting as middle layer between requests coming from a web browser and databases or applications

More information

The Basic Web Server CGI. CGI: Illustration. Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems 4

The Basic Web Server CGI. CGI: Illustration. Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems 4 CMPUT 391 Database Management Systems The Basic Web based Applications, - - CMPUT 391 Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems

More information

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests What is the servlet? Servlet is a script, which resides and executes on server side, to create dynamic HTML. In servlet programming we will use java language. A servlet can handle multiple requests concurrently.

More information

JAVA SERVLET. Server-side Programming INTRODUCTION

JAVA SERVLET. Server-side Programming INTRODUCTION JAVA SERVLET Server-side Programming INTRODUCTION 1 AGENDA Introduction Java Servlet Web/Application Server Servlet Life Cycle Web Application Life Cycle Servlet API Writing Servlet Program Summary 2 INTRODUCTION

More information

INTRODUCTION TO SERVLETS AND WEB CONTAINERS. Actions in Accord with All the Laws of Nature

INTRODUCTION TO SERVLETS AND WEB CONTAINERS. Actions in Accord with All the Laws of Nature INTRODUCTION TO SERVLETS AND WEB CONTAINERS Actions in Accord with All the Laws of Nature Web server vs web container Most commercial web applications use Apache proven architecture and free license. Tomcat

More information

Session 9. Introduction to Servlets. Lecture Objectives

Session 9. Introduction to Servlets. Lecture Objectives Session 9 Introduction to Servlets Lecture Objectives Understand the foundations for client/server Web interactions Understand the servlet life cycle 2 10/11/2018 1 Reading & Reference Reading Use the

More information

Java Servlets. Preparing your System

Java Servlets. Preparing your System Java Servlets Preparing to develop servlets Writing and running an Hello World servlet Servlet Life Cycle Methods The Servlet API Loading and Testing Servlets Preparing your System Locate the file jakarta-tomcat-3.3a.zip

More information

Enterprise Java Technologies (Part 1 of 3) Component Architecture. Overview of Java EE. Java Servlets

Enterprise Java Technologies (Part 1 of 3) Component Architecture. Overview of Java EE. Java Servlets ID2212 Network Programming with Java Lecture 10 Enterprise Java Technologies (Part 1 of 3) Component Architecture. Overview of Java EE. Java Servlets Leif Lindbäck, Vladimir Vlassov KTH/ICT/SCS HT 2015

More information

UNIT-V. Web Servers: Tomcat Server Installation:

UNIT-V. Web Servers: Tomcat Server Installation: UNIT-V Web Servers: The Web server is meant for keeping Websites. It Stores and transmits web documents (files). It uses the HTTP protocol to connect to other computers and distribute information. Example:

More information

Servlet Basics. Agenda

Servlet Basics. Agenda Servlet Basics 1 Agenda The basic structure of servlets A simple servlet that generates plain text A servlet that generates HTML Servlets and packages Some utilities that help build HTML The servlet life

More information

sessionx Desarrollo de Aplicaciones en Red A few more words about CGI CGI Servlet & JSP José Rafael Rojano Cáceres

sessionx Desarrollo de Aplicaciones en Red A few more words about CGI CGI Servlet & JSP José Rafael Rojano Cáceres sessionx Desarrollo de Aplicaciones en Red José Rafael Rojano Cáceres http://www.uv.mx/rrojano A few more words about Common Gateway Interface 1 2 CGI So originally CGI purpose was to let communicate a

More information

Advanced Web Technology

Advanced Web Technology Berne University of Applied Sciences Dr. E. Benoist Winter Term 2005-2006 Presentation 1 Presentation of the Course Part Java and the Web Servlet JSP and JSP Deployment The Model View Controler (Java Server

More information

This tutorial will teach you how to use Java Servlets to develop your web based applications in simple and easy steps.

This tutorial will teach you how to use Java Servlets to develop your web based applications in simple and easy steps. About the Tutorial Servlets provide a component-based, platform-independent method for building Webbased applications, without the performance limitations of CGI programs. Servlets have access to the entire

More information

Stateless -Session Bean

Stateless -Session Bean Stateless -Session Bean Prepared by: A.Saleem Raja MCA.,M.Phil.,(M.Tech) Lecturer/MCA Chettinad College of Engineering and Technology-Karur E-Mail: asaleemrajasec@gmail.com Creating an Enterprise Application

More information

CS506 Web Design & Development Final Term Solved MCQs with Reference

CS506 Web Design & Development Final Term Solved MCQs with Reference with Reference I am student in MCS (Virtual University of Pakistan). All the MCQs are solved by me. I followed the Moaaz pattern in Writing and Layout this document. Because many students are familiar

More information

Introduction to Java Servlets. SWE 432 Design and Implementation of Software for the Web

Introduction to Java Servlets. SWE 432 Design and Implementation of Software for the Web Introduction to Java Servlets James Baldo Jr. SWE 432 Design and Implementation of Software for the Web Web Applications A web application uses enabling technologies to 1. make web site contents dynamic

More information

Chettinad College of Engineering and Technology CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY

Chettinad College of Engineering and Technology CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY UNIT IV SERVLETS 1. What is Servlets? a. Servlets are server side components that provide a powerful mechanism

More information

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2 Java Servlets Adv. Web Technologies 1) Servlets (introduction) Emmanuel Benoist Fall Term 2016-17 Introduction HttpServlets Class HttpServletResponse HttpServletRequest Lifecycle Methods Session Handling

More information

LAB 1 PREPARED BY : DR. AJUNE WANIS ISMAIL FACULTY OF COMPUTING UNIVERSITI TEKNOLOGI MALAYSIA

LAB 1 PREPARED BY : DR. AJUNE WANIS ISMAIL FACULTY OF COMPUTING UNIVERSITI TEKNOLOGI MALAYSIA LAB 1 PREPARED BY : DR. AJUNE WANIS ISMAIL FACULTY OF COMPUTING UNIVERSITI TEKNOLOGI MALAYSIA Setting up Java Development Kit This step involves downloading an implementation of the Java Software Development

More information

SSC - Web applications and development Introduction and Java Servlet (I)

SSC - Web applications and development Introduction and Java Servlet (I) SSC - Web applications and development Introduction and Java Servlet (I) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics What will we learn

More information

Servlets by Example. Joe Howse 7 June 2011

Servlets by Example. Joe Howse 7 June 2011 Servlets by Example Joe Howse 7 June 2011 What is a servlet? A servlet is a Java application that receives HTTP requests as input and generates HTTP responses as output. As the name implies, it runs on

More information

4.1 The Life Cycle of a Servlet 4.2 The Java Servlet Development Kit 4.3 The Simple Servlet: Creating and compile servlet source code, start a web

4.1 The Life Cycle of a Servlet 4.2 The Java Servlet Development Kit 4.3 The Simple Servlet: Creating and compile servlet source code, start a web UNIT - 4 Servlet 4.1 The Life Cycle of a Servlet 4.2 The Java Servlet Development Kit 4.3 The Simple Servlet: Creating and compile servlet source code, start a web browser and request the servlet, example

More information

QuickSpecs. Compaq NonStop Transaction Server for Java Solution. Models. Introduction. Creating a state-of-the-art transactional Java environment

QuickSpecs. Compaq NonStop Transaction Server for Java Solution. Models. Introduction. Creating a state-of-the-art transactional Java environment Models Bringing Compaq NonStop Himalaya server reliability and transactional power to enterprise Java environments Compaq enables companies to combine the strengths of Java technology with the reliability

More information

Distributed Systems 1

Distributed Systems 1 95-702 Distributed Systems 1 Joe Intro Syllabus highlights 95-702 Distributed Systems 2 Understand the HTTP application protocol Request and response messages Methods / safety / idempotence Understand

More information

&' () - #-& -#-!& 2 - % (3" 3 !!! + #%!%,)& ! "# * +,

&' () - #-& -#-!& 2 - % (3 3 !!! + #%!%,)& ! # * +, ! "# # $! " &' ()!"#$$&$'(!!! ($) * + #!,)& - #-& +"- #!(-& #& #$.//0& -#-!& #-$$!& 1+#& 2-2" (3" 3 * * +, - -! #.// HttpServlet $ Servlet 2 $"!4)$5 #& 5 5 6! 0 -.// # 1 7 8 5 9 2 35-4 2 3+ -4 2 36-4 $

More information

servlets and Java JSP murach s (Chapter 2) TRAINING & REFERENCE Mike Murach & Associates Andrea Steelman Joel Murach

servlets and Java JSP murach s (Chapter 2) TRAINING & REFERENCE Mike Murach & Associates Andrea Steelman Joel Murach Chapter 4 How to develop JavaServer Pages 97 TRAINING & REFERENCE murach s Java servlets and (Chapter 2) JSP Andrea Steelman Joel Murach Mike Murach & Associates 2560 West Shaw Lane, Suite 101 Fresno,

More information

JDBC [Java DataBase Connectivity]

JDBC [Java DataBase Connectivity] JDBC [Java DataBase Connectivity] Introduction Almost all the web applications need to work with the data stored in the databases. JDBC is Java specification that allows the Java programs to access the

More information

2. Follow the installation directions and install the server on ccc. 3. We will call the root of your installation as $TOMCAT_DIR

2. Follow the installation directions and install the server on ccc. 3. We will call the root of your installation as $TOMCAT_DIR Installing a Web Server 1. Install a sample web server, which supports Servlets/JSPs. A light weight web server is Apache Tomcat server. You can get the server from http://tomcat.apache.org/ 2. Follow

More information

SERVLETS INTERVIEW QUESTIONS

SERVLETS INTERVIEW QUESTIONS SERVLETS INTERVIEW QUESTIONS http://www.tutorialspoint.com/servlets/servlets_interview_questions.htm Copyright tutorialspoint.com Dear readers, these Servlets Interview Questions have been designed especially

More information

NonStop as part of a modern state of the art IT Infrastructure

NonStop as part of a modern state of the art IT Infrastructure NonStop as part of a modern state of the art IT Infrastructure GTUG & Connect 2012, Dresden Tobias Kallfass, EMEA NED Presales Buzzwords from the IT world Remote Function Call Service-oriented Architecture

More information

Enterprise Java Unit 1- Chapter 4 Prof. Sujata Rizal Servlet API and Lifecycle

Enterprise Java Unit 1- Chapter 4 Prof. Sujata Rizal Servlet API and Lifecycle Introduction Now that the concept of servlet is in place, let s move one step further and understand the basic classes and interfaces that java provides to deal with servlets. Java provides a servlet Application

More information

Servlets and JSP (Java Server Pages)

Servlets and JSP (Java Server Pages) Servlets and JSP (Java Server Pages) XML HTTP CGI Web usability Last Week Nan Niu (nn@cs.toronto.edu) CSC309 -- Fall 2008 2 Servlets Generic Java2EE API for invoking and connecting to mini-servers (lightweight,

More information

Supplement IV.E: Tutorial for Tomcat For Introduction to Java Programming By Y. Daniel Liang

Supplement IV.E: Tutorial for Tomcat For Introduction to Java Programming By Y. Daniel Liang Supplement IV.E: Tutorial for Tomcat 5.5.9 For Introduction to Java Programming By Y. Daniel Liang This supplement covers the following topics: Obtaining and Installing Tomcat Starting and Stopping Tomcat

More information

Advanced Internet Technology Lab # 4 Servlets

Advanced Internet Technology Lab # 4 Servlets Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2011 Advanced Internet Technology Lab # 4 Servlets Eng. Doaa Abu Jabal Advanced Internet Technology Lab # 4 Servlets Objective:

More information

Using Java servlets to generate dynamic WAP content

Using Java servlets to generate dynamic WAP content C H A P T E R 2 4 Using Java servlets to generate dynamic WAP content 24.1 Generating dynamic WAP content 380 24.2 The role of the servlet 381 24.3 Generating output to WAP clients 382 24.4 Invoking a

More information

Session 8. Reading and Reference. en.wikipedia.org/wiki/list_of_http_headers. en.wikipedia.org/wiki/http_status_codes

Session 8. Reading and Reference. en.wikipedia.org/wiki/list_of_http_headers. en.wikipedia.org/wiki/http_status_codes Session 8 Deployment Descriptor 1 Reading Reading and Reference en.wikipedia.org/wiki/http Reference http headers en.wikipedia.org/wiki/list_of_http_headers http status codes en.wikipedia.org/wiki/_status_codes

More information

AJP. CHAPTER 5: SERVLET -20 marks

AJP. CHAPTER 5: SERVLET -20 marks 1) Draw and explain the life cycle of servlet. (Explanation 3 Marks, Diagram -1 Marks) AJP CHAPTER 5: SERVLET -20 marks Ans : Three methods are central to the life cycle of a servlet. These are init( ),

More information

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22.

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22. Answers 1. What is the super interface to all the JDBC Drivers, specify their fully qualified name? a. Java.sql.Driver i. JDBC-ODBC Driver ii. Java-Native API Driver iii. All Java Net Driver iv. Java Native

More information

Unit 4 - Servlet. Servlet. Advantage of Servlet

Unit 4 - Servlet. Servlet. Advantage of Servlet Servlet Servlet technology is used to create web application, resides at server side and generates dynamic web page. Before Servlet, CGI (Common Gateway Interface) was popular as a server-side programming

More information

Handout 31 Web Design & Development

Handout 31 Web Design & Development Lecture 31 Session Tracking We have discussed the importance of session tracking in the previous handout. Now, we ll discover the basic techniques used for session tracking. Cookies are one of these techniques

More information

Servlets. An extension of a web server runs inside a servlet container

Servlets. An extension of a web server runs inside a servlet container Servlets What is a servlet? An extension of a web server runs inside a servlet container A Java class derived from the HttpServlet class A controller in webapplications captures requests can forward requests

More information

Introduction. This course Software Architecture with Java will discuss the following topics:

Introduction. This course Software Architecture with Java will discuss the following topics: Introduction This course Software Architecture with Java will discuss the following topics: Java servlets Java Server Pages (JSP s) Java Beans JDBC, connections to RDBMS and SQL XML and XML translations

More information

Introduction to Servlets. After which you will doget it

Introduction to Servlets. After which you will doget it Introduction to Servlets After which you will doget it Servlet technology A Java servlet is a Java program that extends the capabilities of a server. Although servlets can respond to any types of requests,

More information

PRODUCT DOCUMENTATION. Installing and Implementing Enterprise Contact Center Chat RELEASE 5.1

PRODUCT DOCUMENTATION. Installing and Implementing Enterprise Contact Center Chat RELEASE 5.1 PRODUCT DOCUMENTATION Installing and Implementing Enterprise Contact Center Chat RELEASE 5.1 Document and Software Copyrights Copyright 1998 2009 ShoreTel, Inc. All rights reserved. Printed in the United

More information

Questions and Answers. A. A DataSource is the basic service for managing a set of JDBC drivers.

Questions and Answers. A. A DataSource is the basic service for managing a set of JDBC drivers. Q.1) What is, in terms of JDBC, a DataSource? A. A DataSource is the basic service for managing a set of JDBC drivers B. A DataSource is the Java representation of a physical data source C. A DataSource

More information

The Structure and Components of

The Structure and Components of Web Applications The Structure and Components of a JEE Web Application Sample Content garth@ggilmour.com The Structure t of a Web Application The application is deployed in a Web Archive A structured jar

More information

Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p.

Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p. Preface p. xiii Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p. 11 Creating the Deployment Descriptor p. 14 Deploying Servlets

More information

Java Programming Course Overview. Duration: 35 hours. Price: $900

Java Programming Course Overview. Duration: 35 hours. Price: $900 978.256.9077 admissions@brightstarinstitute.com Java Programming Duration: 35 hours Price: $900 Prerequisites: Basic programming skills in a structured language. Knowledge and experience with Object- Oriented

More information

This course is intended for Java programmers who wish to write programs using many of the advanced Java features.

This course is intended for Java programmers who wish to write programs using many of the advanced Java features. COURSE DESCRIPTION: Advanced Java is a comprehensive study of many advanced Java topics. These include assertions, collection classes, searching and sorting, regular expressions, logging, bit manipulation,

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Java Server Pages (JSP) Dr. Basem Suleiman Service Oriented Computing Group, CSE, UNSW Australia Semester 1, 2016, Week 3 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2442

More information

JdbcResultSet.java. import java.sql.*;

JdbcResultSet.java. import java.sql.*; 1)Write a program to display the current contents of the tables in the database where table name is Registration and attributes are id,firstname,lastname,age. JdbcResultSet.java import java.sql.*; public

More information

Session 9. Deployment Descriptor Http. Reading and Reference. en.wikipedia.org/wiki/http. en.wikipedia.org/wiki/list_of_http_headers

Session 9. Deployment Descriptor Http. Reading and Reference. en.wikipedia.org/wiki/http. en.wikipedia.org/wiki/list_of_http_headers Session 9 Deployment Descriptor Http 1 Reading Reading and Reference en.wikipedia.org/wiki/http Reference http headers en.wikipedia.org/wiki/list_of_http_headers http status codes en.wikipedia.org/wiki/http_status_codes

More information

Table of Contents. Introduction... xxi

Table of Contents. Introduction... xxi Introduction... xxi Chapter 1: Getting Started with Web Applications in Java... 1 Introduction to Web Applications... 2 Benefits of Web Applications... 5 Technologies used in Web Applications... 5 Describing

More information

Chapter 2 How to structure a web application with the MVC pattern

Chapter 2 How to structure a web application with the MVC pattern Chapter 2 How to structure a web application with the MVC pattern Murach's Java Servlets/JSP (3rd Ed.), C2 2014, Mike Murach & Associates, Inc. Slide 1 Objectives Knowledge 1. Describe the Model 1 pattern.

More information

The Servlet Life Cycle

The Servlet Life Cycle The Servlet Life Cycle What is a servlet? Servlet is a server side component which receives a request from a client, processes the request and sends a content based response back to the client. The Servlet

More information

Unit-4: Servlet Sessions:

Unit-4: Servlet Sessions: 4.1 What Is Session Tracking? Unit-4: Servlet Sessions: Session tracking is the capability of a server to maintain the current state of a single client s sequential requests. Session simply means a particular

More information

Fast Track to Java EE

Fast Track to Java EE Java Enterprise Edition is a powerful platform for building web applications. This platform offers all the advantages of developing in Java plus a comprehensive suite of server-side technologies. This

More information

Tutorial: Developing a Simple Hello World Portlet

Tutorial: Developing a Simple Hello World Portlet Venkata Sri Vatsav Reddy Konreddy Tutorial: Developing a Simple Hello World Portlet CIS 764 This Tutorial helps to create and deploy a simple Portlet. This tutorial uses Apache Pluto Server, a freeware

More information

To follow the Deitel publishing program, sign-up now for the DEITEL BUZZ ON-

To follow the Deitel publishing program, sign-up now for the DEITEL BUZZ ON- Ordering Information: Advanced Java 2 Platform How to Program View the complete Table of Contents Read the Preface Download the Code Examples To view all the Deitel products and services available, visit

More information

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003 Introduction This course Software Architecture with Java will discuss the following topics: Java servlets Java Server Pages (JSP s) Java Beans JDBC, connections to RDBMS and SQL XML and XML translations

More information

SQL DML and DB Applications, JDBC

SQL DML and DB Applications, JDBC SQL DML and DB Applications, JDBC Week 4.2 Week 4 MIE253-Consens 1 Schedule Week Date Lecture Topic 1 Jan 9 Introduction to Data Management 2 Jan 16 The Relational Model 3 Jan. 23 Constraints and SQL DDL

More information

Servlet 5.1 JDBC 5.2 JDBC

Servlet 5.1 JDBC 5.2 JDBC 5 Servlet Java 5.1 JDBC JDBC Java DataBase Connectivity Java API JDBC Java Oracle, PostgreSQL, MySQL Java JDBC Servlet OpenOffice.org ver. 2.0 HSQLDB HSQLDB 100% Java HSQLDB SQL 5.2 JDBC Java 1. JDBC 2.

More information

Using the JBoss IDE for Eclipse

Using the JBoss IDE for Eclipse Using the JBoss IDE for Eclipse Important: Some combinations of JBoss/JBoss-IDE/Eclipse do not like to work with each other. Be very careful about making sure all the software versions are compatible.

More information

Database Applications Recitation 6. Project 3: CMUQFlix CMUQ s Movies Recommendation System

Database Applications Recitation 6. Project 3: CMUQFlix CMUQ s Movies Recommendation System 15-415 Database Applications Recitation 6 Project 3: CMUQFlix CMUQ s Movies Recommendation System 1 Project Objective 1. Set up a front-end website with PostgreSQL as the back-end 2. Allow users to login,

More information

Demonstration of Servlet, JSP with Tomcat, JavaDB in NetBeans

Demonstration of Servlet, JSP with Tomcat, JavaDB in NetBeans Demonstration of Servlet, JSP with Tomcat, JavaDB in NetBeans Installation pre-requisites: NetBeans 7.01 or above is installed; Tomcat 7.0.14.0 or above is installed properly with NetBeans; (see step 7

More information

Web Application Architecture (based J2EE 1.4 Tutorial)

Web Application Architecture (based J2EE 1.4 Tutorial) Web Application Architecture (based J2EE 1.4 Tutorial) Dr. Kanda Runapongsa (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University 1 Agenda Web application, components and container

More information

Module 4: SERVLET and JSP

Module 4: SERVLET and JSP 1.What Is a Servlet? Module 4: SERVLET and JSP A servlet is a small Java program that runs within a Web server. Servlets receive and respond to requests from Web clients, usually across HTTP, the Hyper

More information

JDBC Architecture. JDBC API: This provides the application-to- JDBC Manager connection.

JDBC Architecture. JDBC API: This provides the application-to- JDBC Manager connection. JDBC PROGRAMMING JDBC JDBC Java DataBase Connectivity Useful for database driven applications Standard API for accessing relational databases Compatible with wide range of databases Current Version JDBC

More information

SYLLABUS JAVA COURSE DETAILS. DURATION: 60 Hours. With Live Hands-on Sessions J P I N F O T E C H

SYLLABUS JAVA COURSE DETAILS. DURATION: 60 Hours. With Live Hands-on Sessions J P I N F O T E C H JAVA COURSE DETAILS DURATION: 60 Hours With Live Hands-on Sessions J P I N F O T E C H P U D U C H E R R Y O F F I C E : # 4 5, K a m a r a j S a l a i, T h a t t a n c h a v a d y, P u d u c h e r r y

More information

HP Business Availability Center

HP Business Availability Center HP Business Availability Center for the Windows and Solaris operating systems Software Version: 8.00 Embedded UCMDB Applets Using Direct Links Document Release Date: January 2009 Software Release Date:

More information

Servlet and JSP Review

Servlet and JSP Review 2006 Marty Hall Servlet and JSP Review A Recap of the Basics 2 JSP, Servlet, Struts, JSF, AJAX, & Java 5 Training: http://courses.coreservlets.com J2EE Books from Sun Press: http://www.coreservlets.com

More information

The Design of JDBC The Structured Query Language Basic JDBC Programming Concepts Query Execution Scrollable and Updatable Result Sets

The Design of JDBC The Structured Query Language Basic JDBC Programming Concepts Query Execution Scrollable and Updatable Result Sets Course Name: Advanced Java Lecture 13 Topics to be covered The Design of JDBC The Structured Query Language Basic JDBC Programming Concepts Query Execution Scrollable and Updatable Result Sets Introducing

More information

Java servlets CSCI 470: Web Science Keith Vertanen Copyright 2013

Java servlets CSCI 470: Web Science Keith Vertanen Copyright 2013 Java servlets CSCI 470: Web Science Keith Vertanen Copyright 2013 Overview Dynamic web content genera2on (thus far) CGI Web server modules Server- side scrip2ng e.g. PHP, ASP, JSP Custom web server Java

More information

Principles and Techniques of DBMS 6 JSP & Servlet

Principles and Techniques of DBMS 6 JSP & Servlet Principles and Techniques of DBMS 6 JSP & Servlet Haopeng Chen REliable, INtelligent and Scalable Systems Group (REINS) Shanghai Jiao Tong University Shanghai, China http://reins.se.sjtu.edu.cn/~chenhp

More information

Configuring Tomcat for a Web Application

Configuring Tomcat for a Web Application Configuring Tomcat for a Web Application In order to configure Tomcat for a web application, files must be put into the proper places and the web.xml file should be edited to tell Tomcat where the servlet

More information

HP XP P9000 Remote Web Console Messages

HP XP P9000 Remote Web Console Messages HP XP P9000 Remote eb Console Messages Abstract This document lists the error codes and error messages for HP XP P9000 Remote eb Console for HP XP P9000 disk arrays, and provides recommended action for

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2411 1 Review:

More information

Questions and Answers

Questions and Answers Q.1) Servlet mapping defines A. An association between a URL pattern and a servlet B. An association between a URL pattern and a request page C. An association between a URL pattern and a response page

More information

access to a JCA connection in WebSphere Application Server

access to a JCA connection in WebSphere Application Server Understanding connection transitions: Avoiding multithreaded access to a JCA connection in WebSphere Application Server Anoop Ramachandra (anramach@in.ibm.com) Senior Staff Software Engineer IBM 09 May

More information

SQL in a Server Environment

SQL in a Server Environment SQL in a Server Environment Vaidė Narváez Computer Information Systems January 13th, 2011 The Three-Tier Architecture Application logic components Copyright c 2009 Pearson Education, Inc. Publishing as

More information

SECTION II: JAVA SERVLETS

SECTION II: JAVA SERVLETS Chapter 7 SECTION II: JAVA SERVLETS Working With Servlets Working with Servlets is an important step in the process of application development and delivery through the Internet. A Servlet as explained

More information

Customizing ArcIMS Using the Java Connector and Python

Customizing ArcIMS Using the Java Connector and Python Customizing ArcIMS Using the Java Connector and Python Randal Goss The ArcIMS Java connector provides the most complete and powerful object model for creating customized ArcIMS Web sites. Java, however,

More information

Lecture 2. Introduction to JDBC

Lecture 2. Introduction to JDBC Lecture 2 Introduction to JDBC Introducing JDBC According to Sun, JDBC is not an acronym, but is commonly misinterpreted to mean Java DataBase Connectivity JDBC: is an API that provides universal data

More information

PSD1B Advance Java Programming Unit : I-V. PSD1B- Advance Java Programming

PSD1B Advance Java Programming Unit : I-V. PSD1B- Advance Java Programming PSD1B Advance Java Programming Unit : I-V PSD1B- Advance Java Programming 1 UNIT I - SYLLABUS Servlets Client Vs Server Types of Servlets Life Cycle of Servlets Architecture Session Tracking Cookies JDBC

More information

Introdução a Servlets

Introdução a Servlets Introdução a Servlets Sumário 7.1.1.Introdução 7.1.2.Servlet Overview and Architecture 7.1.2.1 Interface Servlet and the Servlet Life Cycle 7.1.2.2 HttpServlet Class 7.1.2.3 HttpServletRequest Interface

More information

First Servlets. Chapter. Topics in This Chapter

First Servlets. Chapter. Topics in This Chapter First Servlets Chapter Topics in This Chapter The basic structure of servlets A simple servlet that generates plain text The process of compiling, installing, and invoking servlets A servlet that generates

More information

JavaEE Interview Prep

JavaEE Interview Prep Java Database Connectivity 1. What is a JDBC driver? A JDBC driver is a Java program / Java API which allows the Java application to establish connection with the database and perform the database related

More information

Introduction to JSP and Servlets Training 5-days

Introduction to JSP and Servlets Training 5-days QWERTYUIOP{ Introduction to JSP and Servlets Training 5-days Introduction to JSP and Servlets training course develops skills in JavaServer Pages, or JSP, which is the standard means of authoring dynamic

More information

Allenhouse Institute of Technology (UPTU Code : 505) OOT Notes By Hammad Lari for B.Tech CSE V th Sem

Allenhouse Institute of Technology (UPTU Code : 505) OOT Notes By Hammad Lari for B.Tech CSE V th Sem ECS-503 Object Oriented Techniques UNIT-5 Course Jdbc... 1 Servlets... 17 JDBC --> The database is the heart of any enterpries system which is used to store and retrieve the data of enterprise more efficiently.

More information

CIS 455 / 555: Internet and Web Systems

CIS 455 / 555: Internet and Web Systems 1 Background CIS 455 / 555: Internet and Web Systems Spring, 2010 Assignment 1: Web and Application Servers Milestone 1 due February 3, 2010 Milestone 2 due February 15, 2010 We are all familiar with how

More information

Module 3 Web Component

Module 3 Web Component Module 3 Component Model Objectives Describe the role of web components in a Java EE application Define the HTTP request-response model Compare Java servlets and JSP components Describe the basic session

More information

How to structure a web application with the MVC pattern

How to structure a web application with the MVC pattern Objectives Chapter 2 How to structure a web application with the MVC pattern Knowledge 1. Describe the Model 1 pattern. 2. Describe the Model 2 (MVC) pattern 3. Explain how the MVC pattern can improve

More information

JSP. Common patterns

JSP. Common patterns JSP Common patterns Common JSP patterns Page-centric (client-server) CLIENT JSP or Servlet CLIENT Enterprise JavaBeans SERVER DB Common JSP patterns Page-centric 1 (client-server) Page View request response

More information

UNIT III - JDBC Two Marks

UNIT III - JDBC Two Marks UNIT III - JDBC Two Marks 1.What is JDBC? JDBC stands for Java Database Connectivity, which is a standard Java API for databaseindependent connectivity between the Java programming language and a wide

More information

Servlets Basic Operations

Servlets Basic Operations Servlets Basic Operations Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu/~spring Overview Preparing to

More information

1. PhP Project. Create a new PhP Project as shown below and click next

1. PhP Project. Create a new PhP Project as shown below and click next 1. PhP Project Create a new PhP Project as shown below and click next 1 Choose Local Web Site (Apache 24 needs to be installed) Project URL is http://localhost/projectname Then, click next We do not use

More information