The following post provides an example of a simple JSP page and instructions on how to deploy and view it. It assumes the use of Eclipse and JBoss.
Create a new Dynamic Web Project in Eclipse called HelloWorld.You can accept the defaults, such as "WebContent" for the web root.
Create the file HelloWorld.jsp under the WebContent directory and paste the following code in:
<%@ page language="java" %>
<html>
<body>
<%
for (int counter = 1; counter <= 10; counter++) {
%>
Hello World!<br>
<%
}
%>
</body>
</html>
Create a file called web.xml under the WEB-INF directory (which should have been automatically created under the WebContent directory) and paste in the following:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
</web-app>
Right-click the HelloWorld project folder and select Run As -> Run on Server. Accept any defaults and run it on your local server. This should put a war file in C:\Apps\JBoss\jboss-5.1.0.GA\server\default\deploy (or equivalent).
Now go to http://localhost:8080/HelloWorld/HelloWorld.jsp and you should see:
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Simple.
0 comments:
Post a Comment