|
Home TOC Index |
|
Search
Feedback |
Updating Web Clients
During development, you will often need to make changes to Web clients. To update a servlet you modify the source file, recompile the servlet class, update the component in the WAR, and redeploy the application. Except for the compilation step, you update a JSP page in the same way.
To try this feature, first build, package, and deploy the JSP version of the Hello application:
- Go to
j2eetutorial/examples/srcand build the example by runningant hello2.- Create a J2EE application called
Hello2App.
- Select File
New
Application.
- In the file chooser, navigate to
j2eetutorial/examples/src/web/hello2.- In the File Name field, enter
Hello2App.- Click New Application.
- Click OK.
- Create the WAR and add the
greetingWeb component and all of theHello2Appapplication content.
- Invoke the Web component wizard by selecting File
New
Web Component.
- In the combo box labeled Create New WAR File in Application select
Hello2App. EnterHello2WARin the field labeled WAR Display Name.- Click Edit to add the content files.
- In the Edit Contents dialog box, navigate to
examples/build/web/hello2. Selectgreeting.jsp,response.jsp, andduke.waving.gif, and click Add. Click OK.- Click Next.
- Select the JSP radio button.
- Click Next.
- Select
greeting.jspfrom the JSP Filename combo box.- Click Finish.
- Add the alias
/greetingfor thegreetingWeb component.- Specify the context root
hello2.- Deploy
Hello2App.- Execute the application by pointing a Web browser at
http://<host>:8000/hello2/greeting. Replace<host>with the name of the host running the J2EE server.Now modify one of the JSP files. For example, you could replace the contents of
response.jspwith the following:<h2>Hi, <%=username%>!</h2>To update the file in the WAR and redeploy the application:
- Edit
response.jsp.- Execute
ant hello2to copy the modified file to the build directory.- Select
Hello2App.- In
deploytool, select ToolsUpdate Files.
- A dialog box appears reporting the changed file.Verify that
response.jsphas been changed and dismiss the dialog box.- Select Tools
Deploy. Make sure the checkbox labeled Save Object Before Deploying is checked.
You can also perform steps 4 through 6 by selecting Tools
Update And Redeploy. The
deploytoolutility replaces the old JSP file inHello2App.earwith the new one and then redeploys the application.When you execute the application, the response should be changed (Figure 9-3)
|
Home TOC Index |
|
Search
Feedback |