⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8.mht

📁 Enterprise Java Bean的PPT文档,很好的东西.
💻 MHT
📖 第 1 页 / 共 5 页
字号:
From: <由 Microsoft Internet Explorer 5 保存>
Subject: Chapter8 - Creating Web Clients
Date: Sun, 5 Dec 2004 11:54:26 +0800
MIME-Version: 1.0
Content-Type: multipart/related;
	boundary="----=_NextPart_000_009C_01C4DAC1.2B501B70";
	type="text/html"
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441

This is a multi-part message in MIME format.

------=_NextPart_000_009C_01C4DAC1.2B501B70
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.tusc.com.au/tutorial/html/chap8.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Chapter8 - Creating Web Clients</TITLE>
<META http-equiv=3DCONTENT-TYPE content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1479" name=3DGENERATOR>
<META content=3D"Glen McCallum and Vishal Sharma" name=3DAUTHOR>
<META content=3D20030729;9513900 name=3DCREATED>
<META content=3DVishal name=3DCHANGEDBY>
<META content=3D20031013;14430800 name=3DCHANGED>
<META=20
content=3D"Tutorial for building J2EE Applications using Eclipse, =
Lomboz, Jboss and Xdoclet."=20
name=3DDESCRIPTION>
<META=20
content=3D"Tutorial, J2EE, Lomboz, Eclipse, Jboss, Xdoclet, J2EE =
Patterns, EJB, Servlets, JSP, BMP, CMP, Session, Configuration, DAO"=20
name=3DKEYWORDS>
<META content=3D"14 days" name=3Drevisit-after><!-- Meta tags --><!-- =
Copyright =C2=A9 2003 TUSC. All rights reserved.--><!--- Header =
--></HEAD>
<BODY lang=3Den-US dir=3Dltr>
<FORM name=3DsearchForm action=3D../../../../search/index.php =
method=3Dpost>
<TABLE style=3D"PAGE-BREAK-BEFORE: always" cellSpacing=3D0 =
cellPadding=3D4=20
width=3D"100%" bgColor=3D#0a6a91 border=3D0>
  <TBODY>
  <TR>
    <TD vAlign=3Dtop width=3D154>
      <P><A href=3D"http://www.tusc.com.au./contact_us.php"><IMG =
height=3D125=20
      alt=3DTUSC=20
      =
src=3D"http://www.tusc.com.au/tutorial/images/header/tuscJ2eeLogo.gif"=20
      width=3D149 align=3Dbottom border=3D0 =
name=3DGraphic1></A></P></TD>
    <TD vAlign=3Dtop width=3D276>
      <P><IMG height=3D73 alt=3D"Reliable, On-Time Delivery."=20
      src=3D"http://www.tusc.com.au/tutorial/images/header/reliable.gif" =
width=3D268=20
      align=3Dbottom border=3D0 name=3DGraphic2><!--search table =
--></P></TD>
    <TD width=3D21></TD>
    <TD width=3D43>
      <P><IMG height=3D9 alt=3DSearch=20
      src=3D"http://www.tusc.com.au/tutorial/images/elements/search.gif" =
width=3D41=20
      align=3Dbottom border=3D0 name=3DGraphic3></P></TD>
    <TD width=3D119>
      <P><INPUT maxLength=3D50 size=3D12 name=3DKEYWORD></P></TD>
    <TD width=3D31>
      <P><INPUT type=3Dimage height=3D18 width=3D29=20
      src=3D"http://www.tusc.com.au/tutorial/images/btns/go.gif" =
align=3Dbottom=20
      name=3Dgo><INPUT type=3Dhidden value=3DY =
name=3DSECTION_ALL></P></TD>
    <TD vAlign=3Dtop width=3D50>
      <P><IMG height=3D73 alt=3DSpacer=20
      src=3D"http://www.tusc.com.au/tutorial/images/invis.gif" =
width=3D50=20
      align=3Dbottom border=3D0 name=3DGraphic5></P></TD>
    <TD vAlign=3Dtop width=3D154>
      <P><A href=3D"http://www.tusc.com.au./contact_us.php"><IMG =
height=3D125=20
      alt=3DTUSC=20
      =
src=3D"http://www.tusc.com.au/tutorial/images/header/tuscJ2eeLogo.gif"=20
      width=3D149 align=3Dbottom border=3D0 =
name=3DGraphic1></A></P></TD>
    <TD width=3D14>
      <P><IMG height=3D10 alt=3Dspacer=20
      src=3D"http://www.tusc.com.au/tutorial/images/invis.gif" =
width=3D14=20
      align=3Dbottom border=3D0 name=3DGraphic58> =
</P></TD></TR></TBODY></TABLE></FORM>
<H2 align=3Dcenter><!--- Header finished -->Tutorial for building J2EE=20
Applications using JBOSS and ECLIPSE <IMG height=3D2=20
src=3D"http://www.tusc.com.au/tutorial/images/redrulr5.gif" width=3D775 =
align=3Dmiddle=20
border=3D0 name=3DGraphic1></H2>
<P><BR><BR></P>
<H1>Chapter 8. </H1>
<P><IMG height=3D2 =
src=3D"http://www.tusc.com.au/tutorial/images/blurulr6.gif"=20
width=3D785 align=3Dmiddle border=3D0 name=3DGraphic2></P>
<H2>Creating Web Clients</H2>
<P>This chapter describes how to create web clients in the Client=20
Tier/Presentation Tier to access or otherwise communicate with the =
Business=20
Tier. Servlets and JSP pages are the two examples of web clients which =
will be=20
created. In a typical Model View Controller Pattern, the Servlet acts as =
the=20
Controller whilst JSP pages act as the View (the Model being the data, =
of=20
course).</P>
<P><IMG height=3D210=20
src=3D"http://www.tusc.com.au/tutorial/images/chap8/J2EECaseStudyFlowDiag=
ram.png"=20
width=3D707 align=3Dleft border=3D0 name=3DGraphic6><BR =
clear=3Dleft><BR><BR></P>
<H3>Tasks :</H3>
<OL>
  <LI>
  <P>Create a Servlet named AccessController under the package=20
  au.com.tusc.servlet.</P>
  <LI>
  <P><FONT color=3D#000000>Add a business method to StoreAccess Bean =
named=20
  getAllItems() with the following signature</FONT></P>
  <P><B><FONT color=3D#000000>public</FONT> <FONT=20
  color=3D#000000>java.util.ArrayList</FONT> <FONT=20
  color=3D#000000>getAllItems()</FONT></B></P>
  <LI>
  <P>Implement the init method.</P>
  <LI>
  <P>Implement doGet and doPost methods.</P>
  <LI>
  <P>Add a method processRequest with the following signature</P>
  <P><B>protected void processRequest (HttpServletRequest=20
  request,HttpServletResponseresponse)</B></P>
  <P><B>throwsServletException, IOException </B></P>
  <LI>
  <P>Implement the processRequest method.</P>
  <LI>
  <P>Deploy the AccessController Servlet.</P>
  <LI>
  <P>Test the AccessContoller Servlet.</P>
  <LI>
  <P><FONT color=3D#000000><FONT face=3D"Bitstream Vera Serif">Create a =
JSP Page=20
  named showItems.</FONT></FONT></P>
  <LI>
  <P>Modify the method processRequest in Servlet AccessController.</P>
  <LI>
  <P><FONT color=3D#000000><FONT face=3D"Nimbus Roman No9 L"><FONT=20
  face=3D"Bitstream Vera Serif">Add HTML and JSP tags to display a list =
of all=20
  items in MyStore.</FONT> </FONT></FONT></P>
  <LI>
  <P>Deploy the module OnlineStore.</P>
  <LI>
  <P><FONT color=3D#000000><FONT face=3D"Bitstream Vera Serif">Test the=20
  showItems.jsp page.</FONT></FONT></P></LI></OL>
<H3 style=3D"MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in"><BR></H3>
<H3 style=3D"MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in"><B>Create =
AccessController=20
Servlet :</B></H3>
<P style=3D"MARGIN-BOTTOM: 0in"><BR></P>
<P><B>Go To Package Explorer &gt; Expand Mystore (project) node &gt; =
select src,=20
right click and a menu will pop up.</B></P>
<P><B>On the pop up menu &gt; New &gt; Lomboz Servlet Wizard as shown=20
below.</B></P>
<P><IMG height=3D414=20
src=3D"http://www.tusc.com.au/tutorial/images/chap8/LombozServletWizard.p=
ng"=20
width=3D536 align=3Dleft border=3D0 name=3DGraphic7><BR =
clear=3Dleft><BR><BR></P>
<P><B>Enter the package name au.com.tusc.servlet, with servlet name=20
AccessController and select four methods to be implemented in the =
servlet as=20
shown.</B></P>
<P><IMG height=3D542=20
src=3D"http://www.tusc.com.au/tutorial/images/chap8/CreateServletWizard.p=
ng"=20
width=3D792 align=3Dleft border=3D0 name=3DGraphic8><BR =
clear=3Dleft><BR><BR></P>
<P><B>Press Next. A new screen will appear as shown below. Add Web =
Module=20
(Browse.. web module and it will show list of web modules in this =
project), in=20
this case it is OnlineStore, so select that. Enter the Servlet name</B> =
<B>as=20
access, and Mapping URL as ' /access/* '</B>.</P>
<P><IMG height=3D566=20
src=3D"http://www.tusc.com.au/tutorial/images/chap8/CreateServletWizardNe=
xt.png"=20
width=3D812 align=3Dleft border=3D0 name=3DGraphic9><BR =
clear=3Dleft><B>Press=20
Finish.</B></P>
<P><B>This will create a package named au.com.tusc.servlet under src and =

AccessController within that package as shown below.</B></P>
<P><IMG height=3D506=20
src=3D"http://www.tusc.com.au/tutorial/images/chap8/AccessControllerServl=
et.png"=20
width=3D668 align=3Dleft border=3D0 name=3DGraphic10><BR =
clear=3Dleft><B>As can be seen=20
from the figure above the four methods we selected in the wizard are =
created,=20
and only their implementation is required.</B></P>
<P><B>Apart from this, some descriptors are generated in web.xml, under=20
Web-Module OnlineStore/WEB-INF as shown below:</B></P>
<P><IMG height=3D548 =
src=3D"http://www.tusc.com.au/tutorial/images/chap8/webxml.png"=20
width=3D458 align=3Dleft border=3D0 name=3DGraphic11><BR =
clear=3Dleft><B>These tags are=20
generated by the Servlet Creation Wizard, where &lt;url-pattern&gt; tag=20
specifies the path name by which the servlet will to be accessed. In =
this case=20
it will be http://localhost:8080/OnlineStore/access. (N.B. - It's not =
necessary=20
to have the same &lt;servlet-name&gt; and &lt;url-pattern&gt;.)</B></P>
<P><B>Web.xml contains all the deployment descriptors required for =
deployment of=20
servlets</B>.</P>
<P>Lomboz creates two pages when you create your web module, index.jsp =
and=20
error.jsp.</P>
<P>Before we go further and start getting our hands dirty with servlets, =
let's=20
have a look at what directories and files are generated by Lomboz under =
Web=20
Modules, in this case OnlineStore, as shown below.</P>
<P><IMG height=3D290=20

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -