Home | | Internet & World Wide Web HOW TO PROGRAM | | Internet Programming | | Web Programming | Creating and Running a Simple Application in Netbeans

Chapter: Internet & World Wide Web HOW TO PROGRAM - Rich Internet Application Server Technologies - JavaServer™ Faces Web Applications

| Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail |

Creating and Running a Simple Application in Netbeans

Our first example displays the web server’s time of day in a browser window. When run, this program displays the text "Current Time on the Web Server", followed by the web server’s time.

Creating and Running a Simple Application in Netbeans

 

Our first example displays the web server’s time of day in a browser window. When run, this program displays the text "Current Time on the Web Server", followed by the web server’s time. The application contains a single web page and, as mentioned previously, consists of two related files—a JSP file (Fig. 26.1) and a supporting page bean file (Fig. 26.3). The application also has the three scoped data beans for request, session, and application scopes. Since this application does not store data, these beans are not used in this example. We first discuss the markup in the JSP file, the code in the page bean file and the application output, then we provide step-by-step instructions for creating the pro-gram. [Note: The markup in Fig. 26.1 and other JSP file listings in this chapter is the same as the markup that appears in Netbeans, but we have reformatted these listings for presen-tation purposes to make the code more readable.]

 

1  <?xml version = "1.0" encoding = "UTF-8"?>

 

2

24 <!-- Fig. 26.1: Time.jsp -->

 

25<!-- JSP file generated by Netbeans that displays -->

 

26<!-- the current time on the web server -->

 

27<jsp:root version = "1.2"

 

28       xmlns:f = "http://java.sun.com/jsf/core"

 

29       xmlns:h = "http://java.sun.com/jsf/html"

 

30       xmlns:jsp = "http://java.sun.com/JSP/Page"

 

31         xmlns:webuijsf = "http://www.sun.com/webui/webuijsf">

 

32         <jsp:directive.page contentType = "text/html;charset=UTF-8"

 

33                pageEncoding = "UTF-8" />

 

34         <f:view>

 

35                <webuijsf:page binding = "#{Time.page1}" id = "page1">

 

<webuijsf:html binding = "#{Time.html1}" id = "html1">

                        <webuijsf:head binding = "#{Time.head1}" id = "head1"                     

17                    title = "Web Time: A Simple Example">              

18                    <webuijsf:link binding = "#{Time.link1}" id = "link1"                 

19                                url = "/resources/stylesheet.css"/>                       

20                    <webuijsf:meta content = "60" httpEquiv = "refresh" />                       

21                    </webuijsf:head>                

22        <webuijsf:body binding = "#{Time.body1}" id = "body1"          

23                    style = "-rave-layout: grid">           

24                    <webuijsf:form binding = "#{Time.form1}" id = "form1">          

25                                <webuijsf:staticText binding = "#{Time.timeHeader}"               

26                                id = "timeHeader" style = "font-size: 18px;                      

27                                left: 24px; top: 24px; position: absolute"             

28                                text = "Current time on the web server:" />                     

29                                <webuijsf:staticText binding = "#{Time.clockText}"       

30                                id = "clockText" style = "background-color: black;         

31                                color: yellow; font-size: 18px; left: 24px; 

32                                top: 48px; position: absolute" />   

33                    </webuijsf:form>      

1     </webuijsf:body>

 

2                         </webuijsf:html>

 

3                   </webuijsf:page>

 

4             </f:view>

 

5      </jsp:root>

 

Fig. 26.1 | JSP file generated by Netbeans that displays the current time on the web server.

Netbeans generates all the markup shown in Fig. 26.1 when you set the web page’s title, drag two Static Text components onto the page and set the properties of the Static Text components. Static Text components display text that cannot be edited by the user. We show these steps shortly.


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail


Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.