Frequently Asked Questions
Note: If you want to learn how to use the most current releases of Tomcat and Java, we highly recommend using the 2nd Edition of this book.
The FAQs for Murach's Java Servlets and JSP deal with a common issue: how to use the book with later releases of Tomcat, Java, and MySQL than those that are on the CD. There are quick-start answers below. If you have other questions or comments, please send an email to murachbooks@murach.com
The relative paths used in the servlets presented in this book (such as "../webapps/murach/WEB-INF/etc/UserEmail.txt") aren't working correctly on my system. How can I fix this?
Here's a way that you can fix the problem while still using a relative path:
1) Comment out the statement that uses the relative path in the servlet:
//UserIO.addRecord(user,
//"../webapps/murach/WEB-INF/etc/UserEmail.txt");
2) Replace that statement with these three statements:
ServletContext sc = getServletContext();
String path = sc.getRealPath("WEB-INF/etc/UserEmail.txt");
UserIO.addRecord(user, path);
I want to use the current releases of Java (JDK 5) and Tomcat (version 5.5) instead of the releases that come on your book's CD. Will your book still work?
Yes, it will, but some of the code is affected by the new releases. So be sure to review the chapter-by-chapter summary that we've prepared as a PDF document. It identifies all of the changes
that you need to make to get all of the applications, examples,
and exercises in the book to work with Java 5.0 and Tomcat 5.5.
I'm using version 4.1 of Tomcat, and I can't get any of the servlets presented in your book to work. How can I get them to work?
In most versions of Tomcat 4.1, the mapping for the invoker servlet has been disabled. You can get all of the servlets presented in this book to work with Tomcat 4.1 by enabling the invoker servlet. To do that, you can open the web.xml file that's stored in Tomcat's conf directory (tomcatDir/conf/web.xml) and remove the comments from these lines of code:
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
This maps the invoker servlet for all web applications running under Tomcat. If that's not what you want to do, you can add the code shown above to the web.xml files for the murach and musicStore applications presented in this book.
For more details on how to modify the applications, examples, and exercises in the book so they'll work with Tomcat 4.1, please see the chapter-by-chapter summary that we've prepared.
I'm using version 5.0 of Tomcat, and I can't get any of the servlets presented in your book to work. How can I get them to work?
You can get all of the servlets presented in this book to work with Tomcat 5.0 by enabling the invoker servlet. To do that, you start by opening the web.xml file that's stored in Tomcat's conf directory (tomcatDir/conf/web.xml). Then, you need to do two things. First, you need to remove the comments from the code that defines the name for the invoker servlet:
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
Then, you need to remove the comments from the code that maps the invoker servlet:
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
This maps the invoker servlet for all web applications running under Tomcat. If that's not what you want to do, you can add the code shown above to the web.xml files for the murach and musicStore applications presented in this book.
The SQL scripts on the book's CD don't work for me. What's wrong?
The SQL scripts work for versions of MySQL that are earlier than 4.1. If you're working with MySQL 4.1 or later, you can download updated versions of these scripts and run them instead of the ones that are on the CD.
|