第4章にあるMurachのJavaサーブレットとJSPを使用しています。http://ボタンをロードすると、エラーが発生します。誰もが問題の原因を知ることができますか?私はすべてのファイルをtomcat / webapps/MailListに保存しています。私はこのコードを何時間も調べましたが、問題の原因となる構文を見つけることができません。別の目でおそらくそれを捕まえるだろうと思っています。または、誰かがそれを説明することができます、どんな助けでも大歓迎です、これはサーブレット/JSPとTomcatをいじる私の最初の日です。
join_email_list.html _
<!DOCTYPE html>
<html>
<head>
<title>Chapter 4 - Email List application</title>
</head>
<body background="C:\Users\Public\Pictures\Sample Pictures\Lighthouse.jpg" >
<h1>Join the Murach's mailing list</h1>
<p>To join the Murach's mailing list, enter your name and email address below.<br>
Then, click n the submit to recieve special offers.</p>
<form action="show_email_entry.jsp" method="get">
<table cellspacing="5">
<tr>
<td align="right" >First name</td>
<td><input type="text" name="firstName"></td>
</tr>
<tr>
<td align="right">Last name</td>
<td><input type="text" name="lastName"></td>
</tr>
<tr>
<td align="right">email address</td>
<td><input type="text" name="emailAddress"></td>
</tr>
<tr>
<td></td>
<td><br><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
show_email_list.jsp _
<!DOCTYPE html public"-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Chapter 4 - Email List</title>
</head>
<body>
<%@page import="business.*, data.*" %>
<%
String firstName = request.getParameter("firstName");
String lastName = request.getParameter("lastName");
String emailAddress = request.getParameter("emailAddress");
User user = new User(firstName, lastName, emailAddress);
UserIO.addRecord(user, "..webapps/MailingList/UserEmail.txt");
%>
<h1>Thanks for joining</h1>
<table cellspacing="5">
<tr>
<td align="right">First Name: </td>
<td><%= user.getFirstName() %></td>
</tr>
<tr>
<td align="right">Last Name: </td>
<td><%= user.getLastName() %></td>
</tr>
<tr>
<td align="right">Email Address: </td>
<td><%= user.getEmailAddress() %></td>
</tr>
</table>
<form action="join_email_list.html" method="post">
<input type="submit" value="Return">
</form>
</body>
</html>
User.javaクラス_
package business;
public class User {
private String firstName;
private String lastName;
private String emailAddress;
//this class defines a user, what we can get from a user to store
public User(){}
public User(String first, String last, String email){
firstName=first;
lastName=last;
emailAddress=email;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
}
UserIO.javaクラス_
package data;
import business.User;
import java.io.*;
public class UserIO { //the user io class adds the entered info to a txt file a.k.a psuedo db
public synchronized static void addRecord(User user, String fileName)
throws IOException{
PrintWriter out = new PrintWriter( //open the printwriter
new FileWriter(fileName, true)); //write to file
out.println(user.getEmailAddress()+"|"//write these things to file
+user.getFirstName()+"|"
+user.getLastName());
out.close();//close out to free resources
}
}