Home arrow Java arrow Page 5 - JavaServer Pages
JAVA

JavaServer Pages


If you've taken a look at J2EE and JavaServer Pages technology, and want to examine JSP more closely, you've come to the right place. This article, the first of two parts, 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).

Author Info:
By: Apress Publishing
Rating: 4 stars4 stars4 stars4 stars4 stars / 10
November 03, 2005
TABLE OF CONTENTS:
  1. · JavaServer Pages
  2. · Writing JSP Pages
  3. · Scriptlets
  4. · Template Data
  5. · Try It Out: Deploying the Web Application in J2EE
  6. · Try It Out: Deploying the Web Application in Tomcat
  7. · Action Elements

print this article
SEARCH DEVARTICLES

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.


blog comments powered by Disqus
JAVA ARTICLES

- Java Too Insecure, Says Microsoft Researcher
- Google Beats Oracle in Java Ruling
- 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 ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials