Building Dynamic Web sites with JSP (2)

Source: Internet
Author: User
Tags include interface modify
js| Dynamic Four, the unified website interface

JSP supports server-side file inclusion, that is, you can insert multiple other files in a JSP file to achieve a unified web interface. Modify the above hi.jsp and save as mypage.jsp:

<%@ include file= "top.htm"%>
<%
String MSG = "This JSP test.";
Out.print ("Hello world!");
%>
<%=Msg%>
<%@ include file= "bot.htm"%>


With the visual HTML editor, such as FrontPage, Dreamweave, and other design Web site framework structure, the design of the frame structure file divided into two parts, the upper half of the above save as top.htm, the following half saved as bot.htm, the code as follows:

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> My home page </title>
<body>
<table border= "0" width= "100%" cellpadding= "4" cellspacing= "0" align= "center"
<tr>
<TD width= "100%" colspan= "2" bgcolor= "#837ED1" align= "center" ><font face= "Official script"
Color= "#FFFF00" size=5> home page title </font>
</td>
</tr>
<tr>
<TD bgcolor= "#837ED1" width= "15%" valign= "Top" align= "center" > <br>
<font color= "#FFFFFF" > option </font> <p> <font color= "#FFFFFF" > options </font> </p>
<p> <font color= "#FFFFFF" > options </font> </p>
<p> <font color= "#FFFFFF" > ... </font> </p>
<p> </p>
</td>
<TD width= "85%" valign= "Top"
--------------------------------------------------------------------------------------------------------------- -
</td>
</tr>
</table>
</body>


Type http://localhost:8080/mypage.jsp in the address bar of the browser. So the interface of the site can be unified, and designers can focus on the function module to deal with user login, connect the database, send email and so on. Each JSP file has the following structure:


<%@ include file= "top.htm"%>
<%
Implement some features
%>
<%@ include file= "bot.htm"%>


Maintaining the site's interface is also relatively easy, as long as you modify top.htm and bot.htm, you can affect all pages.

Five, server parameter setting

The JSWDK Web server parameter is saved in \jswdk-1.0.1\webserver.xml, and the default setting value can be modified by opening and editing the file with Windows WordPad. This section focuses on a slightly different setting for Tomcat under Jswdk,linux.

JSWDK The default document directory is \jswdk-1.0.1\webpages, where subdirectories, such as \jswdk-1.0.1\webpages\test, can be created in a browser http://localhost/ Test access to this directory, in order to enable this subdirectory to execute the JSP program, you must also add in the <Service> </Service> section in Webserver.xml:

<webapplication id= "test" mapping= "/test" docbase= "webpages/test"/>

Also, you must create a \jswdk-1.0.1\webpages\test\web-inf directory and copy it from the \jswdk-1.0.1\webpages\web-inf directory: Mappings.properties, Mime.properties, Servlets.properties and Webapp.properties. Complete these procedures to notify the JSWDK Web server of executing JSP programs in Http://localhost/test.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.