Java Tutorial - Java Script :
Running the Application
Now, we are ready to launch our application! We invoke our application from our browser with the following URL:
http://localhost:8080/oldfriends Figure 7.3 shows the resulting output of index.jsp. Let’s examine what went on here. The Tomcat servlet container invoked index.jsp because it is configured in the welcome-file in web.xml. The first couple of lines in index.jsp are references to the Struts tag libraries, struts-html.tld and struts-bean.tld. The HTML tag libraries provide tags that can be used to provide basic functionality in the creation of HTML screens, such as forms, input fields, links, and so on. The bean tag libraries provide functionality for accessing the properties of Java Beans, and as we saw earlier, Java Beans are prevalent in the Struts architecture. You will notice that the declaration begins with taglib uri=, telling where the tag library descriptor is located; the prefix= simply tells us how we can reference the tags in our JSP.
<%@ taglib uri=”/WEB-INF/struts-html.tld” prefix=”html” %>
<%@ taglib uri=”/WEB-INF/struts-bean.tld” prefix=”bean” %>
The name of our organization, “Mullins High School ” is not embedded in index.jsp. Instead, we make use of the ApplicationResources .properties file to define our organization.
oldfriends.highschool=Mullins High School
This allows us to repurpose the application for another school without making changes to the code. With the information stored the properties file, we can use the convenience of our bean tag libraries to extract it and insert it into our output, as shown below.
<TITLE><bean:message key=”oldfriends.highschool”/></TITLE>
We have leveraged the Struts HTML tag libraries to construct the form:
<html:form action=”oldfriends.do”>
the input fields:
<html:text property=”userID” />
<html:password property=”password” />
and links for getting to other parts of our application (which we will look at later):
<html:form action=”startregister.do”>
<html:submit> Register </html:submit>
</html:form>
