Good day!
I, honestly, have been searching the posts all day and digging through various reference material ...
I am trying to build the example
JSP project (FAQ) provided in "Web Development with
Java Server Pages" by Duane K. Fields and Mark A. Kolb. I am learning a GREAT deal from this book! And a lot more from this site!!
When launcing the URL:
http://localhost:8080/faqtool I am presented with the directory listing rather than launching a
servlet that should present me with a JSP page. I understand that the URL is not to change when navigating through this application???
Additionally, clicking on some of the JSP pages in the directory will result in the error:
2001-03-06 03:27:50 - Ctx( /faqtool ): JasperException: R( /faqtool + /all.jsp + null) Unable to load class FaqBean
I have ensured that my PATH, CLASSPATH, etc., variables are set correctly.
CLASSPATH = C:\jdk1.3.0_02\lib;C:\j2sdkee1.3\lib;C:\foo\tomcat;
C:\IBM Connectors\classes;C:\IBMCON~1\CICS\Classes\CTGCLI~1.JAR
J2EE_HOME = C:\j2sdkee1.3
JAVA_HOME = C:\jdk1.3.0_02
Path = C:\jdk1.3.0_02\bin;C:\j2sdkee1.3\bin;C:\IBMDebug\bin;
C:\IBM Connectors\Encina\bin;
C:\IBMCON~1\CICS\BIN;%SystemRoot%\system32;%SystemRoot%;
%SystemRoot%\System32\Wbem;C:\Program Files\Symantec\pcAnywhere;C:\IMNnq_NT;C:\foo;C:\IBM;
TOMCAT_HOME = C:\foo\tomcat
The actual Tomcat/FAQ app file path:
C:\foo\tomcat\webapps\faqtool\WEB-INF\classes\com\taglib\wdjsp\faqtool
"faqtool" contains all of my class files.
I have created the appropriate directories for the class files, configured the server.xml (for
Tomcat) and the web.xml (for the FAQ app), but still can get this thing to work.
SERVER.XML (typical settings excluded):
.........................................................
<Context path="/faqtool"
docBase="webapps/faqtool"
isWARExpanded="true"
crossContext="false"
debug="0"
reloadable="true" >
</Context>
.........................................................
WEB.XML:
.........................................................
<?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>
<display-name>Web Development with JSP</display-name>
<servlet>
<servlet-name>faqs</servlet-name>
<servlet-class>com.taglib.wdjsp.faqtool.FaqServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>faqtool</servlet-name>
<servlet-class>com.taglib.wdjsp.faqtool.FaqAdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>faqs</servlet-name>
<url-pattern>/faqs</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>faqtool</servlet-name>
<url-pattern>/faqtool</url-pattern>
</servlet-mapping>
</web-app>
.........................................................
Here is the FaqAdminServlet code:
.........................................................
package com.taglib.wdjsp.faqtool;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class FaqAdminServlet extends HttpServlet {
private HashMap commands;
private
String error = "error.jsp";
private String jspdir = "/jsp/";
public void init(ServletConfig config) throws ServletException {
super.init(config);
initCommands();
}
public void service(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException {
String next;
try {
Command cmd = lookupCommand(req.getParameter("cmd"));
next = cmd.execute(req);
CommandToken.set(req);
}
catch (CommandException e) {
req.setAttribute("javax.servlet.jsp.jspException", e);
next = error;
}
RequestDispatcher rd;
rd = getServletContext().getRequestDispatcher(jspdir + next);
rd.forward(req, res);
}
private Command lookupCommand(String cmd)
throws CommandException {
if (cmd == null)
cmd = "main-menu";
if (commands.containsKey(cmd.toLowerCase()))
return (Command)commands.get(cmd.toLowerCase());
else
throw new CommandException("Invalid Command Identifier");
}
private void initCommands() {
commands = new HashMap();
commands.put("main-menu", new NullCommand("menu.jsp"));
commands.put("abort", new AbortCommand("menu.jsp"));
commands.put("add", new NullCommand("add.jsp"));
commands.put("do-add", new AddCommand("menu.jsp"));
commands.put("update-menu", new GetAllCommand("upd_menu.jsp"));
commands.put("update", new GetCommand("update.jsp"));
commands.put("do-update", new UpdateCommand("menu.jsp"));
commands.put("delete-menu", new GetAllCommand("del_menu.jsp"));
commands.put("delete", new GetCommand("delete.jsp"));
commands.put("do-delete", new DeleteCommand("menu.jsp"));
}
}
.........................................................
Here is the FaqBean code:
.........................................................
package com.taglib.wdjsp.faqtool;
import java.util.Date;
public class FaqBean {
private int id;
private String question;
private String answer;
private Date lastModified;
public FaqBean() {
this.id = 0;
this.question = "";
this.answer = "";
this.lastModified = new Date();
}
public void setQuestion(String question) {
this.question = question;
this.lastModified = new Date();
}
public String getQuestion() {
return this.question;
}
public void setAnswer(String answer) {
this.answer = answer;
this.lastModified = new Date();
}
public String getAnswer() {
return this.answer;
}
public void setID(int id) {
this.id = id;
}
public int getID() {
return this.id;
}
public Date getLastModified() {
return this.lastModified;
}
public void setLastModified(Date modified) {
this.lastModified = modified;
}
public String toString() {
return "[" + id + "] " + "Q: " + question + "; A: " +
answer + "\n";
}
}
.........................................................
This problem is particulary perplexing because I am able to compile and use other classes within the Tomcat environment.
I just can't seem to get this project off the ground.
I hope that all of this text didn't scare everyone away. This is my first posting. I just wanted to be sure to include as much pertinent info as possible. Thanks in advance!
Darrell
Future
SCJP I edited the classpath to keep this from pushing off the side of the page. The classpath is still complet but, appears on multiple lines ---Carl
[This message has been edited by Carl Trusiak (edited March 07, 2001).]