• No results found

Application Server. Java EE 6 with GlassFish 3. 1 open source' Application Server and develop Java EE 6 applications

N/A
N/A
Protected

Academic year: 2021

Share "Application Server. Java EE 6 with GlassFish 3. 1 open source' Application Server and develop Java EE 6 applications"

Copied!
8
0
0

Loading.... (view fulltext now)

Full text

(1)

Java EE

6

with

GlassFish 3

Application

Server

A

practical guide

to

install

and

configure

the

GlassFish 3

Application

Server and

develop

Java

EE 6

applications

to

be

deployed

to

this

server

David

Heffelfinger

[

1 open

source'

I

community experience distilled PUBLISHING

(2)

Table of Contents

Preface

1

Chapter

1:

Getting

Started with GlassFish

7

Overview of Java EE and GlassFish

7

What's new in Java EE 6

8

JavaServer Faces

(JSF)

2.0 8

EnterpriseJavaBeans

(EJB)

3.1 8

Java Persistence API (JPA)2.0 9 Contexts andDependency Injectionfor Java

(Web

Beans

1.0)

9 Java Servlet API 3.0 9 Java API for RESTful web services

(JAX-RS)

1.1 10

Java API for XML-based web services(JAX-WS)2.2 10 Java Architecture for XMLBinding (JAXB)2.2 10

What's

newin

GlassFish

v3 10

GlassFish

advantages

11

Obtaining

GlassFish

12

Installing

GlassFish

13

GlassFish

dependencies

14

Performing

the

installation

14

Verifying

the installation 21

Deploying

ourfirst Java EE

application

23

Deploying

an

application

throughthe Web Console 23

Undeploying

anapplication through the WebConsole 25

Deploying an

application through

the command line 26

GlassFish domains

29

Creating

domains 29

Deleting

domains 30

Stopping

a domain 31

Setting

up database

connectivity

31

Setting

up

connection

pools

32

(3)

Table

of

Contents

Final

notes

38

Summary

38

Chapter

2:

Servlet

Development

and

Deployment

39

What isa servlet?

39

Writing

ourfirst servlet 41

Compiling

the

servlet

42

Configuring

the servlet 43

Packaging

the web

application

45

Deploying

the web

application

46

Testing

the web

application

47

Processing

HTML

forms

48

Request

forwarding

and

response redirection

55

Request forwarding

55

Response

redirection 58

Persisting

application

dataacross

requests

61

New features introduced

in Servlet 3.0 64

Optional

web.xml

deployment descriptor

64

@WebServletannotation 64

@WebFilter

annotation 67

@WebListener

annotation 70

Pluggability

72

Configuring

webapplications

programmatically

74

Asynchronous processing 76

Summary

79

Chapter

3:

JavaServer

Pages

81

Introduction

to JavaServer

Pages

81

Developing

ourfirst JSP 82

JSP

implicit objects

86

JSPs and JavaBeans 95

Reusing

JSP

content

100

JSP

custom

tags

102

Extending

SimpleTagSupport

102

Using tag

files to create custom JSP

tags

109

Unified

Expression

Language

113

JSP XML

syntax

117

Summary

120

Chapter

4: JSP Standard

Tag Library

121

Core

JSTL

tag library

122

Formatting

JSTL

tag library

130

SQL JSTL

tag

library

135

(4)

JSTL functions

144

Summary

148

Chapter

5: Database

Connectivity

149

The

CustomerDB database

149

JDBC

150

Retrieving

data from a database 151

Modifying

database

data

159

The Java

Persistence API

161

Entity

relationships

168

One-to-onerelationships 168

One-to-many relationships

174

Many-to-many relationships

180

Composite

primary keys

187

Java Persistence

Query Language

192

New features introduced

in

JPA

2.0 195

Criteria API

196

Bean Validation

support

199

Summary

202

Chapter

6: JavaServer Faces

203

Introduction

to

JSF 2.0

203

Facelets

203

Optional faces-config.xml

204

Standardresource locations 204

Developing

ourfirst

JSF

2.0

application

205

Facelets

205

Project

stages

210 Validation 212

Grouping

components

214

Form

submission

214

Managed

beans

215

Managedbean scopes 216

Navigation

217

Custom data validation

218

Creating

custom validators 218

Validator methods 222

Customizing

JSF's default

messages

225

Customizing

message

styles

225

Customizing

message

text

227

Integrating

JSF

and JPA 230

Ajax enabling

JSF 2.0

applications

237

(5)

TableofContents

JSF core

components

242

The <f actionListener>

tag

242 The <f

ajax>

tag 242 The <f attribute>tag 243

The <fconvertDateTime>tag 243

The <fconvertNumber>tag 244

The <f converter

tag

244 The <fevent>tag 244 The <f facet>tag 245

The<floadBundle>tag 245

The <fmetadata>tag 246 The <f param>tag 246 The <f

phaseListener> tag

246 The <f selectltem>tag 246

The <f selectltems> tag 247

The <f

setPropertyActionListener>

tag 247 The <f subview>

tag

247 The <f validateBean>tag 248 The <fvalidateDoubleRange> tag 248 The <f

validateLength>

tag 248 The <f

validateLongRange>

tag 249 The <f

validateRegex> tag

249

The <fvalidateRequired> tag 249 The <f validator> tag 250 The <f

valueChangeListener>

tag 250 The <f verbatim>tag 250 The <f:view>tag 251

The<f:viewParam>tag 251

JSF HTML

components

251

The<h:body> tag 251

The <h:button>tag 251 The <h:column>tag 252 The <h:commandButton>

tag

252

The<h:commandLink>tag 252

The<h:dataTable> tag 253

The <h:form>tag 253

The

<h:graphiclmage>

tag 253

The<h:head> tag 254

The

<h:inputHidden>

tag 254

The

<h:inputSecret>

tag 254

The

<h:inputText> tag

254

The <h:inputTextarea>

tag

254

The <h:link>tag 254

The

<h:message>

tag 255

The

<h:messages> tag

255

The<h:outputFormat>

tag

255

The

<h:outputl_abel>

tag 256

The<

h:outputLink>

tag 256

(6)

The

<h:outputScript> tag

256

The

<h:outputStylesheet>

tag 257

The

<h:outputText>

tag 257

The

<tv.panelGrid>

tag 257

The

<h:panelGroup>

tag 258

The <h:selectBooleanCheckbox>

tag

259 The

<h:selectManyCheckbox>

tag

259 The

<h:selectManyListbox> tag

259 The

<h:selectManyMenu>

tag 260

The<h:selectOneListbox>tag 260 The <h:selectOneMenu>tag 260

The<h:selectOneRadio> tag 260

Additional JSF

component

libraries

261

Summary

261

Chapter

7:

Java

Messaging

Service

263

Setting

up

GlassFish for JMS

263

Setting

up

a

JMS connection

factory

263

Setting

up

a

JMS message queue

266

Setting

up

a JMS message

topic

267

Message

queues

268

Sending

messages to a message queue

268

Retrieving

messages

from

a

message

queue 272

Asynchronously receiving

messages

from a

message queue

275

Browsing

message

queues

278

Message topics

280

Sending

messagesto a message

topic

280

Receiving

messages from

a message

topic

282

Creating

durable

subscribers 284

Summary

287

Chapter

8:

Security

289

Security

realms 289

Predefined

security

realms 290

The admin-realm 291

The file realm 293

The certificate realm 307

Defining

additional realms 315

Definingadditional file realms 315

Defining additional certificate realms 316

Defining

anLDAP realm 318

Defining

aSolaris realm 319

Defining

a JDBC realm 320

Definingcustom realms 326

(7)

Table

of

Contents

Chapter

9:

Enterprise

JavaBeans

333

Session beans

334

Simple

session bean 334

Amore realistic

example

338

Invoking

session beans

from web

applications

340

Singleton

session beans

342

Asynchronous

method calls

343

Message-driven

beans 346

Transactions in

Enterprise

JavaBeans 347

Container-managed

transactions 347

Bean-managed

transactions

350

Enterprise

JavaBeans life

cycle

353

Stateful session bean

life

cycle

353

Stateless session bean life

cycle

356

Message-driven

bean life

cycle

359

EJB

timer

service

359

Calendar-based EJB timer

expressions

363

EJB

security

365

Client authentication

368

Summary

370

Chapter

10: Contexts and

Dependency

Injection

371

Named beans 371

Dependency injection

374

Qualifiers

375

Named bean scopes 379

Summary

388

Chapter

11: Web Services with JAX-WS

389

Developing

web services

with

JAX-WS

389

Developing

aweb service client 394

Sending

attachments to web services 401

Exposing

EJBs as web services

404

EJB web service clients

405

Securing

web services 406

Securing

EJB

web services

408

Summary

410

Chapter

12: RESTful Web Services

with

Jersey

and JAX-RS

411

Introduction

to RESTful web services and JAX-RS 411

Developing

a

simple

RESTful web service

412

Configuring

the RESTresources

path

for

our

application

415

(8)

Configuring

via the

@ApplicationPath

annotation 416

Testing

ourweb

service

417

Converting

data between Java and

XML

with JAXB

420

Developing

a

RESTful web service client

424

Query

and

path parameters

426

Query parameters

426

Sending

queryparametersvia theJerseyclient API 428

Path

parameters

430

Sending path parametersvia theJerseyclient API 432

Summary

434

Appendix

A:

Sending

E-mails

from

Java

EE

Applications

435

Configuring

GlassFish 435

Implementing

e-mail

delivery functionality

439

Appendix

B: IDE

Integration

443

NetBeans

443

Eclipse

445

References

Related documents

Java Enterprise Edition, Sun Java System Application Server, Java Servlet API, JavaServer Pages, JavaServer Faces, Enterprise Java Beans, Java Persistence API, Java Web

Learn to develop applications with the following technologies: Enterprise JavaBeans (EJB), Java Persistence API (JPA), JDBC, Java Transaction API (JTA), Contexts and

 Extra wizards for JAX RS, EJB Singleton,  Java EE 6 Javadoc Code Completion.  Tight integration with GlassFish Java EE 6:  Start, Stop, Debug,

The paper is therefore, out to examine the impact of the foreign exchange market on the economic growth of Nigeria between 1996 to 2005 by considering the rate at

‰ Office furniture for lawyer(s), staff, reception area, file cabinets, conference, room furniture, carpeting and area rugs, book shelves, art work/office decorating needs. ‰

No difference was found in either the inhaled corticosteroid dose or the exacerbation frequency between children with moderate-severe asthma randomised to either standard or

Retrofitting of existing school buildings to improve their seismic resistance seems the most feasible solutions for their protection. Retrofitting an existing building to

The radiography control button was released before the exposure end. The display indicates the remaining exposure time. Based on this time, you must decide whether to develop