SunQuest
 
       Java
  Home arrow Java arrow Page 2 - Finishing the Project: Java Web Developmen...
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  
Actuate Whitepapers 
VeriSign Whitepapers 
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

Finishing the Project: Java Web Development in Eclipse and Tomcat
By: Gangyi
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    2007-05-29

    Table of Contents:
  • Finishing the Project: Java Web Development in Eclipse and Tomcat
  • Create welcome.jsp
  • Run the web application in the Eclipse environment
  • What just happened?

  • 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
     
    Iron Speed
     
    ADVERTISEMENT

    AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th -1:00PM EST. Register Today!

    Finishing the Project: Java Web Development in Eclipse and Tomcat - Create welcome.jsp


    (Page 2 of 4 )

    Creating a JSP page requires taking similar steps as you did for creating an HTML file except for selecting JSP rather than HTML from the context menu. The text of welcome.jsp file is below.

    <html>
    <head>
      <title>Welcome page</title>
    </head>
    <body>
      <pre>
      <%
    Œ
     
    String secreteUser = "user";
     
    String secretePass = "pass";
     
    String username = request.getParameter("username"); Ž
     
    String password = request.getParameter("password");
     
    %>
     
    <%if(!(username.equals(secreteUser) || password.equals(secretePass))) {%>
       
    Wrong username / password
     
    <%} else {%>
       
    Welcome aboard <%=username%>!
     
    <%}%> '
     
    </pre>
    </body>
    </html>

    You can see that JSP is a mixture of HTML elements and Dynamic Java code.

    Everything between the start tag <% Œ and end tag %> is JSP code, in other words, Java code.

    A JSP page may contain the following components:

    • static HTML
    • JSP directives such as the include directive
    • JSP scripting elements and variables
    • JSP actions
    • custom tags

    In this simple JSP, only JSP scripting elements and variables are used.

    You might ask where the request Ž comes from. The request is one of six JSP Implicit Objects: out, page, pageContext, request, session, and config. They can be references from your JSP code directly.

    The code between Œ and features scriptlets just like your Java Code in a method.

    <%=username%> is an expression.

    More Java Articles
    More By Gangyi


     

    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...

    Iron Speed

    Iron Speed





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