Hello guys. I'm getting an error as follows:
Error I get on the browser:-
type Exception report
message:
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception:
org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP
PWC6199: Generated servlet error:
string:///GuestBookView_jsp.java:8: cannot find symbol
symbol : class GuestBook
location: package myApp
PWC6197: An error occurred at line: 5 in the jsp file: /GuestBookView.jsp
PWC6199: Generated servlet error:
string:///GuestBookView_jsp.java:18: cannot find symbol
symbol : class GuestBook
location: class org.apache.jsp.GuestBookView_jsp
PWC6197: An error occurred at line: 11 in the jsp file: /GuestBookView.jsp
PWC6199: Generated servlet error:
string:///GuestBookView_jsp.java:74: cannot find symbol
symbol : class GuestBook
location: class org.apache.jsp.GuestBookView_jsp
PWC6197: An error occurred at line: 11 in the jsp file: /GuestBookView.jsp
PWC6199: Generated servlet error:
string:///GuestBookView_jsp.java:74: cannot find symbol
symbol : class GuestBook
location: class org.apache.jsp.GuestBookView_jsp
PWC6197: An error occurred at line: 85 in the jsp file: /GuestBookView.jsp
PWC6199: Generated servlet error:
string:///GuestBookView_jsp.java:138: cannot find symbol
symbol : class GuestBook
location: class org.apache.jsp.GuestBookView_jsp
PWC6197: An error occurred at line: 85 in the jsp file: /GuestBookView.jsp
PWC6199: Generated servlet error:
string:///GuestBookView_jsp.java:138: cannot find symbol
symbol : class GuestBook
location: class org.apache.jsp.GuestBookView_jsp
PWC6199: Generated servlet error:
Note: string:///GuestBookView_jsp.java from uses unchecked or unsafe operations.
PWC6199: Generated servlet error:
Note: Recompile with -Xlint:unchecked for details.
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.
Here's my code of all the files I need to run this project. Sorry if this is silly but I'm trying to figure out EJB on my own...
Index.jsp:
<%--
Document : index
Created on : Nov 11, 2012, 3:54:12 PM
Author :
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Room Reservation</title>
</head>
<body background="back.jpg">
<h1 style="color:red;">Room Reservation System</h1>
<div style="text-align: center">
<form method="post" action="GuestBookView.jsp" >
<fieldset>
<legend><b><marquee>Enter Details For Room Reservation</marquee></b></legend>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Customer Name:</td>
<td><input type="text" name="cname" value="" size="50" tabindex="1"></td>
</tr>
<tr>
<td>Address</td>
<td><input type="text" name="cadd" value="" size="50" tabindex="1"> </td>
</tr>
<tr>
<td>Phone Number</td>
<td><input type="text" name="cph" value="" size="12" tabindex="1"></td>
</tr>
<tr>
<td>Room Type</td>
<td>
<select name="roomtype">
<option id="g">General</option>
<option id="d">Deluxe</option>
<option id="s">Suite</option>
</select>
</td>
</tr>
<tr>
<td>Check IN Date:</td>
<td><input type="text" name="checkindate" value="" size="12" tabindex="1"></td>
</tr>
<tr>
<td>Check Out Date:</td>
<td><input type="text" name="checkoutdate" value="" size="12" tabindex="1"></td>
</tr>
<tr>
<td>Payment Mode</td>
<td><select name="paymode">
<option id="cash">Cash</option>
<option id="credit">Credit</option>
</select>
</td>
</tr>
<tr> <td colspan="2">
<pre>
</pre>
<input name="cmdSubmit" type="submit" value="Submit" tabindex="4">
</td>
</tr>
</table>
</fieldset>
</form>
</div>
</body>
</html>
GuestBook.java:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package myApp;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "guestbook")
public class GuestBook implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "VisitorNo", unique = true, updatable = false)
private Integer visitorNo;
@Column(name = "VisitorName")
private String visitorName;
@Column(name = "VisitorAddr")
private String visitorAddr;
@Column(name = "VisitorPhone")
private String visitorPhone;
@Column(name = "VisitorRoom")
private String visitorRoom;
@Column(name = "VisitorIn")
private String visitorIn;
@Column(name = "VisitorOut")
private String visitorOut;
@Column(name = "VisitorMode")
private String visitorMode;
public GuestBook() {
}
public GuestBook(Integer visitorNo) {
this.visitorNo = visitorNo;
}
public Integer getVisitorNo() {
return visitorNo;
}
public void setVisitorNo(Integer visitorNo) {
this.visitorNo = visitorNo;
}
public String getVisitorName() {
return visitorName;
}
public void setVisitorName(String visitorName) {
this.visitorName = visitorName;
}
public String getVisitorAddr() {
return visitorAddr;
}
public void setVisitorAddr(String visitorAddr) {
this.visitorAddr = visitorAddr;
}
public String getVisitorPhone() {
return visitorPhone;
}
public void setVisitorPhone(String visitorPhone) {
this.visitorPhone = visitorPhone;
}
public String getVisitorRoom() {
return visitorRoom;
}
public void setVisitorRoom(String visitorRoom) {
this.visitorRoom = visitorRoom;
}
public String getVisitorIn() {
return visitorIn;
}
public void setVisitorIn(String visitorIn) {
this.visitorIn = visitorIn;
}
public String getVisitorOut() {
return visitorOut;
}
public void setVisitorOut(String visitorOut) {
this.visitorOut = visitorOut;
}
public String getVisitorMode() {
return visitorMode;
}
public void setVisitorMode(String visitorMode) {
this.visitorMode = visitorMode;
}
}
GuestBookView.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"
import="java.util.List, java.util.Iterator, myApp.GuestBook, javax.persistence.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%!
private EntityManagerFactory emf;
private EntityManager em;
private EntityTransaction tx;
List<GuestBook> guestbook;
%>
<%
emf = Persistence.createEntityManagerFactory("GuestBookJPAPU");
em = emf.createEntityManager();
String submit = request.getParameter("btnSubmit");
if(submit != null && ("Submit").equals(submit)) {
try {
String cname = request.getParameter("cname");
String cadd = request.getParameter("cadd");
String cph = request.getParameter("cph");
String roomtype = request.getParameter("roomtype");
String checkindate = request.getParameter("checkindate");
String checkoutdate = request.getParameter("checkoutdate");
String paymode = request.getParameter("paymode");
GuestBook gb = new GuestBook();
gb.setVisitorName(cname);
gb.setVisitorAddr(cadd);
gb.setVisitorPhone(cph);
gb.setVisitorRoom(roomtype);
gb.setVisitorIn(checkindate);
gb.setVisitorOut(checkoutdate);
gb.setVisitorRoom(paymode);
tx = em.getTransaction();
tx.begin();
em.persist(gb);
tx.commit();
}
catch (RuntimeException e) {
if(tx != null) tx.rollback();
throw e;
}
response.sendRedirect("GuestBookView.jsp");
}
try {
guestbook = em.createQuery("SELECT g from GuestBook g").getResultList();
}
catch (RuntimeException e) {
throw e;
}
em.close();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title>Guest Book</title>
</head>
<body bgcolor="pink">
<table border="0" cellpadding="0" cellspacing="0" align="center" width="760">
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="60%" valign="top" align="left" style="padding-right:0px; padding-left:0px; padding-bottom:0px; font:24px/30px Georgia; width:228px; color:#786e4e; padding-top:0px; height:37px;">
Room Reservation Results.
</td>
<td valign="bottom" align="right" style="font:12px/16px Georgia, serif; color:#786e4e;">
<b>Click <a href="index.jsp"> here</a> to go back.</b>
</td>
</tr>
</table>
</td>
</tr>
<tr align="left" valign="top">
<td height="20">
<hr />
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%">
<%
Iterator iterator = guestbook.iterator();
while (iterator.hasNext()) {
GuestBook objGb = (GuestBook) iterator.next();
%>
<tr>
<td style="font:12px/16px Georgia; color:#786e4e;">
<b><%=objGb.getVisitorName()%>:</b><br/>
<%=objGb.getVisitorName()%><br/>
<%=objGb.getVisitorAddr()%><br/>
<%=objGb.getVisitorPhone()%><br/>
<%=objGb.getVisitorRoom()%><br/>
<%=objGb.getVisitorIn()%><br/>
<%=objGb.getVisitorOut()%><br/>
<%=objGb.getVisitorMode()%><br/>
<br /><br />
</td>
</tr>
<%
}
%>
</table>
</td>
</tr>
</table>
</body>
</html>