Alright, I am going for the total shotgun question here. I tried to create a basic JSP on a JBoss 6.0 server with Eclipse SR2. I have a JSP file, a Web.XML and the Build.XML all below. Now bare in mind that Eclipse stores the WAR in C:\JBoss\jboss-6.0.0.Final\server\default\deploy\quote.war
The problem is that the files are not appearing on the localhost. I’m trying to make sense of the problem.
So here’s quote.jsp:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="java.util.Random" %>
<%
//Word up.
String[] quotes = {
"Eat my shorts!", "Cowabunga dude!","Oh snap!","Psyche!",
"Talk to the hand!","Different strokes for different folks.",
"Dont go there.","Da Bomb!",
"All that, and a bag of potato chips!"};
ArrayList<String> list = new ArrayList<String>(Arrays.asList(quotes));
Random r = new Random(); /*This creates a new random number generator.*/
int x = r.nextInt(list.size()); /*nextInt finds the next integer of the randomized number, between 0 and the integer provided, in this case, nine possible phrases.*/
String saying = (String)list.get(x); //Not sure why they felt they had to cast this as a string...
pageContext.setAttribute("saying",saying); /*Apparently takes whatever string value to be used within the scope of the HTML?*/
%>
<html>
<head>
<title>Behold! And Despair!</title>
</head>
<body>
<br>
<c:set var="sessionCount" scope="session"
value="${sessionCount +1}" />
<c:set var="applicationCount" scope="application"
value="${applicationCount +1}" />
<h1>
<font color="#1230cb">Catchphrases You Wish Time Forgot</font>
</h1>
<h3>
<br>
<font color="#a6a6a6">
${saying}
<br>-your Childhood
</font>
</h3>
<br><br>
You've visited this application ${sessionCount}
times this session. Perhaps its time to get a life.
<br>
Also, this application has been visited ${applicationCount}
by you and others who also have no social outlet.
</body>
</html>
Here’s the web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/j2ee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>QuoteServlet</servlet-name>
<jsp-file>/quote.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>QuoteServlet</servlet-name>
<url-pattern>/quote</url-pattern>
</servlet-mapping>
</web-app>
And finally, the build.xml:
<project name="quote" basedir="../" default="deploy">
<!-- Project settings -->
<property name="project.distname" value="quote"/>
<!-- Local system paths -->
<property file="${basedir}/ant/build.properties"/>
<property name="webroot.dir" value="${basedir}\WebContent"/>
<property name="webinf.dir" value="${webroot.dir}\WEB-INF"/>
<property name="build.dir" value="build"/>
<!-- classpath for JSF 1.1.01 -->
<path id="compile.classpath">
<pathelement path ="${webinf.dir}/lib/commons-beanutils.jar"/>
<pathelement path ="${webinf.dir}/lib/commons-collections.jar"/>
<pathelement path ="${webinf.dir}/lib/commons-digester.jar"/>
<pathelement path ="${webinf.dir}/lib/commons-logging.jar"/>
<pathelement path ="${webinf.dir}/lib/jsf-api.jar"/>
<pathelement path ="${webinf.dir}/lib/jsf-impl.jar"/>
<pathelement path ="${webinf.dir}/lib/jstl.jar"/>
<pathelement path ="${webinf.dir}/lib/standard.jar"/>
<pathelement path ="${webinf.dir}/classes"/>
<pathelement path ="${classpath.external}"/>
<pathelement path ="${classpath}"/>
</path>
<!-- define your folder for deployment -->
<property name="deploy.dir" value="deploy"/>
<!-- Check timestamp on files -->
<target name="prepare">
<tstamp/>
</target>
<!-- Copy any resource or configuration files -->
<target name="resources">
<copy todir="${webinf.dir}/classes" includeEmptyDirs="no">
<fileset dir="JavaSource">
<patternset>
<include name="**/*.conf"/>
<include name="**/*.properties"/>
<include name="**/*.xml"/>
</patternset>
</fileset>
</copy>
</target>
<!-- Normal build of application -->
<target name="compile" depends="prepare,resources">
<javac srcdir="JavaSource" destdir="${webinf.dir}/classes">
<classpath refid="compile.classpath"/>
</javac>
</target>
<!-- Remove classes directory for clean build -->
<target name="clean"
description="Prepare for clean build">
<delete dir="${webinf.dir}/classes"/>
<mkdir dir="${webinf.dir}/classes"/>
</target>
<!-- Build entire project -->
<target name="build" depends="prepare,compile"/>
<target name="rebuild" depends="clean,prepare,compile"/>
<!-- Create binary distribution -->
<target name="war" depends="build">
<mkdir dir="${build.dir}"/>
<war
basedir="${webroot.dir}"
warfile="${build.dir}/${project.distname}.war"
webxml="${webinf.dir}\web.xml">
<exclude name="WEB-INF/${build.dir}/**"/>
<exclude name="WEB-INF/src/**"/>
<exclude name="WEB-INF/web.xml"/>
</war>
</target>
<target name="deploy" depends="war">
<delete file="${deploy.dir}/${project.distname}.war"/>
<delete dir="${deploy.dir}/${project.distname}"/>
<copy file="${build.dir}/${project.distname}.war" todir="${deploy.dir}"/>
</target>
</project>
Sorry for being a clutter bug here. But advice would be appreciated.
Assuming you deployed your war file under
and started JBoss default profile
and NOT see any errors in your log file
You should be able to see your application deployed and you should be able to access it using http://localhost:8080/quote.jsp or http://localhost:8080/quote/quote.jsp
Hope this helps.
Good luck!