Java
  Home arrow Java arrow Page 5 - JavaServer Pages
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

JavaServer Pages
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2005-11-03

    Table of Contents:
  • JavaServer Pages
  • Writing JSP Pages
  • Scriptlets
  • Template Data
  • Try It Out: Deploying the Web Application in J2EE
  • Try It Out: Deploying the Web Application in Tomcat
  • Action Elements

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    JavaServer Pages - Try It Out: Deploying the Web Application in J2EE


    (Page 5 of 7 )

    That finishes the code for our application, but before it can actually be accessed by clients, we need to deploy our application to an application server. Well look at two application servers in this bookthe reference implementation server that comes with the J2EE SDK, and the Tomcat stand-alone server. First, lets see how we do it with the J2EE server.

    • Ensure the J2EE server is running, and start up the J2EE Deployment Tool that we looked at in the previous chapter.

       

    • Select File | New | Application EAR from the menu to create a new Application EAR file. EAR stands for Enterprise Archive.

       

    • In the dialog that results, enter a filename for the application. I used JavaFAQ.ear for this example:
                                                   


    • Select File | New | Web Application WAR from the menu to create a new web application. This will start the Web Application Wizard:
                                                 

    • At the first screen of the wizard, shown below, ensure the correct application is selected in the Create New WAR Module in Application drop-down box. Click the Edit button in the Contents panel and add these files to the WAR:

      • FaqCategories.class
      • errorPage.jsp
      • footer.jspf
      • welcome.jsp

                              


      Make sure that the errorPage.jsp and footer.jspf files appear in the correct location underneath the WEB-INF directory. If they do not, you can drag and drop them into the correct location. Note that the wizard will create the deployment descriptor, web.xml, for you. You do not need to add web.xml to the application.
    • At the next dialog, select the JSP radio button and click the Next button:
                                              

    • In the JSP Filename drop-down box, select /welcome.jsp as the JSP to define. The Web Component Name and Web Component Display Name fields will be automatically filled. Click the Finish button: 
                                                

       

    • In the navigation pane on the left, ensure the application is selected. In the screenshot below, the web application has been named JavaFAQ, and you can see it is selected. In the right pane, select the Web Context tab, and double-click in the Context Root field. Enter Ch03 as the context root and press Enter
                                                 

       

    • Now select the WebApp label in the left pane. Select the File Refs tab in the right pane. Add an entry for a Welcome File. Enter the welcome.jsp page. 
                                                  

       

    • Ensure the JavaFAQ application is selected in the left-hand pane, and select File | Save As to save the Application EAR. The location doesnt matter, as long as you remember where you save it.

       

    • Select Tools | Deploy from the menu. The Deployment Tool allows you to select the server to which the web application is deployed. Most likely you are deploying to the localhost and will not have any other servers. You can add servers from the File | Add Server selection on the menu. You may also need to enter the admin username and password for the server (hopefully you wrote those down when you installed the J2EE server). When you are ready, click the OK button; the Deployment Tool will deploy your web application.

       

    • A window will open in which the results of the deployment are listed.

       

    • When the tool is finished, open a browser window. Enter the address http://localhost:1024/Ch03. The welcome.jsp page will automatically load: 
                                                

    The address and port you use in the web browser depend on where the server is located and which port it uses to listen for HTTP requests. If you installed the J2EE server to the same machine as the web browser, then you can access it using localhost, or you can use the localhost IP address 127.0.0.1 or the actual IP address of the machine. The default HTTP port for the J2EE reference implementation is 1024, so if you did not keep the default port during installation, you will access the web application using the URL listed previously.

    If, however, you installed the J2EE server to a different machine, or selected a different port for the server to listen for HTTP requests, you will need to change the URL to use the name or IP address of that machine, and the correct port for the server.

    More Java Articles
    More By Apress Publishing


       · This article is an excerpt from the book "Beginning J2EE 1.4 From Novice to...
     

    Buy this book now. This article is excerpted from chapter three of Beginning J2EE 1.4 From Novice to Professional, written by James L. Weaver, Kevin Mukhar, and Jim Crume (Apress, 2004; ISBN: 1590593413). Check it out at your favorite bookstore today. Buy this book now.

    JAVA ARTICLES

    - Deploying Multiple Java Applets as One
    - Deploying Java Applets
    - Understanding Deployment Frameworks
    - Database Programming in Java Using JDBC
    - Extension Interfaces and SAX
    - Entities, Handlers and SAX
    - Advanced SAX
    - Conversions and Java Print Streams
    - Formatters and Java Print Streams
    - Java Print Streams
    - Wildcards, Arrays, and Generics in Java
    - Wildcards and Generic Methods in Java
    - Finishing the Project: Java Web Development ...
    - Generics and Limitations in Java
    - Getting Started with Java Web Development in...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway