Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
62 views

Myhelloworld

This document provides code examples and documentation for a Java web application that demonstrates different Java technologies including JSP, JavaBeans, servlets, and JSTL. It includes code for Java classes like MyHelloWorldBean.java, a servlet class MyHelloWorldServlet.java, JSP files like myhelloworld_bean.jsp and myhelloworld_jstl.jsp, and a web application deployment descriptor web.xml. The application provides different "Hello World" examples to demonstrate these Java web technologies.

Uploaded by

basith_ab2k3
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Myhelloworld

This document provides code examples and documentation for a Java web application that demonstrates different Java technologies including JSP, JavaBeans, servlets, and JSTL. It includes code for Java classes like MyHelloWorldBean.java, a servlet class MyHelloWorldServlet.java, JSP files like myhelloworld_bean.jsp and myhelloworld_jstl.jsp, and a web application deployment descriptor web.xml. The application provides different "Hello World" examples to demonstrate these Java web technologies.

Uploaded by

basith_ab2k3
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

---myhelloworld_bean.

jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>


<%@ page import="myeclipse.MyHelloWorldBean" language="java"%>

<jsp:useBean id="MyHelloWorld" class="myeclipse.MyHelloWorldBean"


scope="session"/>

<html>
<head>
<title>Hello World (JSP & Java Bean Example)</title>
</head>
<body>
<h1 align="center">Hello World (JSP & Java Bean Example)</h1>
Bean Example MyHelloWorld.getStrMyMessage(): <%=
MyHelloWorld.getStrMyMessage() %>
</body>
</html>

--myhelloworld_jstl.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>


<html>
<head>
<title>Hello World (JSTL Example)</title>
</head>
<body>
<h1 align="center">Hello World (JSTL Example)</h1>
JSTL Example (c:out): <c:out value="Hello World"/>
</body>
</html>

 "
 MyHelloWorldServlet.java

package myeclipse;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class MyHelloWorldServlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse


response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Hello World (Servlet Example)</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1 align=\"center\">Hello World (Servlet
Example)</h1>");
out.println("<p>Hello World</p>");
out.println("</body>");
out.println("</html>");
}

--- MyHelloWorldBean.java

package myeclipse;

import java.util.*;

public class MyHelloWorldBean {

String strMyMessage;

public MyHelloWorldBean() {
reset();
}

public void setStrMyMessage(String strSet) {


strMyMessage = strSet;
}

public String getStrMyMessage() {


return strMyMessage;
}

public void reset() {


setStrMyMessage("Hello World");
}

----index.jsp

<html>
<head>
<title>App Index for: mytomcat-eclipse-helloworld</title>
</head>
<body>
<h1 align="center">App Index for: mytomcat-eclipse-helloworld</h1>
<ul>
<li>
<a href="pages/myhelloworld_jstl.jsp">pages/myhelloworld_jstl.jsp</a> -
JSTL Hello World Example
</li>
<li>
<a href="pages/myhelloworld_bean.jsp">pages/myhelloworld_bean.jsp</a> -
JSP & Java Bean Hello World Example
</li>

<li>
<a href="servlet/MyHelloWorldServlet">servlet/MyHelloWorldServlet</a> -
Servlet Hello World Example
</li>

<a href="servlet/HelloWorldExample">
</ul>
</body>
</html>

  web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<display-name>MyEclipse Hello World Examples</display-name>


<description>
Hello World type examples using Eclipse for: JSP, Java Beans, Servlets
</description>

<!-- Define servlets that are included in the example application -->

<servlet>
<servlet-name>MyHelloWorldServlet</servlet-name>
<servlet-class>myeclipse.MyHelloWorldServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>MyHelloWorldServlet</servlet-name>
<url-pattern>/servlet/MyHelloWorldServlet</url-pattern>
</servlet-mapping>

</web-app>

 Directory Structure under: mytomcat-eclipse-helloworld-scratch

List of Directories:

\WEB-INF
\WEB-INF\lib
\WEB-INF\src
\WEB-INF\src\java
\WEB-INF\src\myeclipse
\WEB-INF\classes
\pages

List of files:

\index.jsp
\pages
\pages\myhelloworld_bean.jsp
\pages\myhelloworld_jstl.jsp
\WEB-INF\web.xml
\WEB-INF\lib\jstl.jar - copy this file.
\WEB-INF\lib\standard.jar - copy this file.
\WEB-INF\src\myeclipse\MyHelloWorldBean.java
\WEB-INF\src\myeclipse\MyHelloWorldServlet.java

Java Training Outline


1. The Java Environment
o Overview of Architecture
o Forms for Java Software
o Three Platforms
o Java Virtual Machine
o The Core API
o Java Runtime Environment
o Java SDK
o Java Class Path
o Portability and Efficiency
2. Language Fundamentals
o Source File Format
o Application Classes
o Code Grammar and Expressions
o Identifiers
o Literals
o Operators
o Expressions
o Calling Methods
3. Data Types
o Primitive Types
o Type Conversion
o Numeric Types
o Characters and Booleans
o Java 1.5: Enumerations
o Object References
o Comparing and Assigning References
o Strings
o Arrays
4. Flow Control
o The main Method
o Calling and Returning from Methods
o Conditional Constructs
o Looping Constructs
o Java 1.5: the For-Each Loop
o Processing Arrays
o Recursion
5. Object-Oriented Software
o Complex Systems
o Abstraction
o Classes and Objects
o Responsibilities and Collaborators
o UML
o Relationships
o Visibility
6. Classes and Objects
o Java Classes
o Constructors and Garbage Collection
o Naming Conventions and JavaBeans
o Packages and Imports
o Relationships Between Classes
o Using this
o Visibility
o Overloading Methods
o JARs
7. Inheritance and Polymorphism in Java
o Extending Classes
o Using Derived Classes
o Type Identification
o Compile-Time and Run-Time Type
o Polymorphism
o Overriding Methods
o Superclass Reference
8. Using Classes Effectively
o Class Loading
o Static Members
o Statics and Non-Statics
o Static Initializers
o Prohibiting Inheritance
o Costs of Object Creation
o Strings and StringBuffers
o Controlling Object Creation
9. Interfaces and Abstract Classes
o Separating Interface and Implementation
o UML Interfaces and Realization
o Defining Interfaces
o Implementing and Extending Interfaces
o Abstract Classes
10. Collections
o Dynamic Collections
o Collections vs. Arrays
o The Collections API
o Abstraction: The Collection Interface
o Vector, LinkedList, ArrayList
o Reading Elements and Downcasting
o Collecting Primitive Values
o Algorithmic Programming
o Iterators
o Maps
o Sorted Collections
o Java 1.5: Generics
o Java 1.5: Auto-Boxing
o Java 1.5: Type-Safe Collections
o Java 1.5: Variable Argument Lists
o Java 1.5: Formatted Output
11. Exception Handling
o Reporting and Trapping Errors
o Exception Handling
o Throwing Exceptions
o Declaring Exceptions per Method
o Catching Exceptions
o The finally Block
o Catch-and-Release
o Chaining Exceptions
12. Inner Classes
o Passing Behavior
o Named Inner Classes
o Outer Object Reference
o Static Inner Classes
o Anonymous Inner Classes
13. The Java Streams Model
o Delegation-Based Stream Model
o InputStream and OutputStream
o Media-Based Streams
o Filtering Streams
o Readers and Writers
14. Working with Files=
o File Class
o Modeling Files and Directories
o File Streams
o Random-Access Files
15. Advanced Stream Techniques
o Buffering
o Data Streams
o Push-Back Parsing
o Byte-Array Streams and String Readers and Writers
16. Java Serialization
o The Challenge of Object Serialization
o Serialization API
o Serializable Interface
o ObjectInputStream and ObjectOutputStream
o The Serialization Engine
o Transient Fields
o readObject and writeObject
o Externalizable Interface

Appendix A.  Learning Resources

    

Advanced Java Training


  Course #:  NT106

  Duration:  5 days

Click Here To Request a Custom Quote For Training at Your Site.

Advanced Java Training Overview


nTier's Advanced Java training course focuses on developing software using the Java 2 Platform,
Standard Edition, or J2SE. It is intended for students with solid experience in structured and
object-oriented Java programming, including use of the Collections API and exception handling.
The course software also includes an optional overlay of workspace and project files to support
use of the Eclipse IDE in the classroom.

The course is organized into four modules. The first covers several general-purpose topics such
as writing multi-threaded applications, the Reflection API, and network programming using
sockets. Then the course takes up the challenge of building multi-tier applications using the
standard Java platform. Multi-tier development most frequently uses the Java 2 Platform,
Enterprise Edition, or J2EE, and we have a wide range of courses in that area. However it is
quite possible to build lightweight multi-tier applications using only J2SE, and for some
purposes the J2EE is more trouble than it's worth. So the course looks at each of the traditional
tiers and the J2SE APIs most suited to developing them. The second module of the course covers
the Java Foundation Classes, or JFC, for building graphical user interfaces (GUIs) for the
presentation tier. The third module introduces Java Remote Method Invocation, or RMI, as a
way of distributing Java objects over multiple processes, which may be spread over a network of
machines; this provides a means of developing a separate business tier. Finally, the fourth
module teaches the Java Database Connectivity, or JDBC, API, for the persistence tier.

Students will complete the course with a good working knowledge of each of these technologies,
prepared to build distributed Java applications and to pursue JFC, RMI, or JDBC in greater
depth.

We also offer Introduction to Java training and Intermediate Java training.

Advanced Java Training Learning Objectives


 Write multi-threaded Java applications.
 Use the Reflection API for highly generic tasks, discovery, or code-generation.
 Communicate between processes using network sockets.
 Understand the basics of the JFC architecture.
 Build simple GUI applications using JFC.
 Build more complex GUIs using various JFC controls.
 Use the many hooks into the JFC architecture to easily customize rendering and editing within
JFC controls.
 Understand the significance of the MVC decomposition in using JFC controls.
 Build GUI classes that make effective use of events as fired from model, view and controller
elements of the GUI itself.
 Understand the role of Java RMI in distributed Java software development.
 Understand the relationship between RMI and various J2EE technologies such as JNDI, EJB, and
CORBA.
 Understand the RMI framework and architecture, especially the role of generated stubs and
skeletons.
 Implement simple RMI clients and servers.
 Connect to a database using JDBC and perform a simple query.
 Update relational data using JDBC to execute updates, inserts and deletes.
 Use prepared statements to produce reusable database queries and optimize execution time.
 Use callable statements to access database procedures.
 Use scrollable and updatable results sets for more robust solutions.
 Use commit, rollback, and savepoint to build transactional systems.
 Use batch processing for efficient handling of large datasets

Advanced Java Training Prerequisites

Students must be experienced Java programmers, able to build, test, and debug complex
applications using structured and object- oriented code designs, and familiar with the Collections
API and Java exception-handling.

Advanced Java Training Outline


Module 1. Advanced Java APIs

1. Threads
o Java Thread Model
o Threads and ThreadGroups
o Creating and Running Threads
o Manipulating Thread State
o Creating Thread Classes
o Thread Synchronization
o Java 1.5: Concurrency Library wait and notify join and sleep
2. Reflection Uses for Meta-Data
o The Reflection API
o The Class Class
o The java.lang.reflect Package
o Reading Type Information
o Navigating Inheritance Trees
o Dynamic Instantiation
o Dynamic Invocation
o Java 1.5: Annotations and Aspect-Oriented Programming
3. Serialization
o The Challenge of Object Serialization
o Serialization
o API Serializable Interface
o ObjectInputStream and ObjectOutputStream
o The Serialization Engine
o Transient Fields
o readObject and writeObject
o Externalizable Interface
4. Sockets
o The OSI Reference Model
o Network Protocols
o The Socket Class
o The ServerSocket Class
o Connecting Through URL Objects
o HTTP and Other TCP Servers
o Datagram Clients and Servers
o Non-Blocking Sockets

Module 2. The Java Foundation Classes

1. Introduction to JFC
o Abstract Windowing Toolkit (AWT) Basics
o Simple Layout Management
o Simple Event Handling
o Lightweight Controls
o JFC Feature
o Set JFC Architecture and Relationship to AWT
2. JFC Application Design
o Role of a JFrame
o Building a Frame-Based JFC Application
o Panes Using Dialogs
3. JFC Components
o JFC Component
o Class Hierarchy
o JComponent Features
o Simple Control Types
o Text Components
o Menus
o Managing Look and Feel
4. Architectural Patterns
o Observer Pattern
o Model-View-Controller
o Decomposition
o Strategy Pattern
o JList
o Factory Pattern
o JComboBox

Module 3. Java Remote Method Invocation

1. RMI Architecture
o Motivation for RMI
o RMI and EJB
o RMI and CORBA
o Overview of RMI Architecture
o Stubs and Skeletons
o Remote Reference Layer
o RMI Transport
o Lifetime of a Remote Method Invocation
o RMI Registry
o Naming and URL Resolution
o RMI Up and Running
2. RMI Implementation
o Interface Design
o The Remote Interface
o Implementation Classes
o The RemoteObject and RemoteServer Classes
o The UnicastRemoteObject Class
o Server Implementation
o Using the Registry
o Client Implementation
o Code Deployment
3. Practical RMI
o Stub Source Code
o RMI Marshaling
o Skeleton Source Code
o Diagnostic Code
o Using RemoteServer
o Passing Objects
o The Factory Pattern
o Serialization vs. Remote Reference
o Designing for Latency
o The Value Object Pattern
o Exception Handling

Module 4. Java Database Connectivity

1. Database and SQL Fundamentals


o Relational Databases and SQL Database, Schema, Tables, Columns and Rows
o SQL Versions and Vendor Implementations
o DDL - Creating and Managing Database Objects
o DML - Retrieving and Managing Data Sequences
o Stored Procedures
o Using SQL Terminals
2. JDBC Fundamentals
o What is the JDBC API?
o JDBC Drivers
o Making a Connection
o Creating and Executing a Statement
o Retrieving Values from a ResultSet
o SQL and Java Datatypes
o SQL NULL Versus Java null
o Creating and Updating Tables
o Handling SQL Exceptions and Proper Cleanup
o Handling SQLWarning
3. Advanced JDBC
o SQL Escape Syntax
o Using Prepared Statements
o Using Callable Statements
o Scrollable Result Sets
o Updatable Result Sets
o Transactions Commits, Rollbacks, and Savepoints
o Batch Processing
o Alternatives to JDBC
4. Introduction to Row Sets
o Row Sets in GUI and J2EE programming
o Advantages of RowSets
o RowSet Specializations
o Using CachedRowSets

Appendix A.  Learning Resources

J2EE Patterns Training Prerequisites

Students should have an understanding of Java, Servlets, & JSP’s (EJB's recommended but not
required)

J2EE Patterns Training Outline


1. J2EE Patterns
o Overview
o Identifying a Pattern
o The Tiered Approach
o J2EE Patterns
 Presentation Tier Patterns
 Business Tier Patterns
 Integration Tier Patterns
 Guide to the Catalog
 Terminology
 Use of UML Pattern Template
 J2EE Patterns
 Relationships
 Relationship to Known Patterns
 Patterns
 Roadmap
2. Presentation
o Tier Patterns
o Intercepting Filter
o Front Controller
o Struts ActionServlet Page Controller
o Struts ActionServlet Application Controller
o Struts RequestProcessor View Helper
o Composite View
o Struts Tiles Service to Worker
o Struts Action
3. Business Tier Patterns

o Business Delegate
o Service Locator
o Session Façade
o Application Service
o Business Object
o Composite Entity
o Transfer Object
o Transfer Object Assembler
o Value List Handler
2. Integration Tier Patterns
o Data Access Object
o Service Activator
o Domain Store
o Web Service Broker

Appendix A.  Learning Resources

http://www.michael-thomas.com/tech/index.html (important)

You might also like