我在JSP项目中工作。在使用带有Tomcat 7.0.68服务器的Netbeans运行项目时,我得到以下异常,
HTTP状态500 - 无法为JSP编译类:
HTTP Status 500 - Unable to compile class for JSP:
**type** Exception report
**message** Unable to compile class for JSP:
**description** The server encountered an internal error that prevented it from fulfilling this request.
**exception**
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: [14] in the generated java file: [C:\apache-tomcat-7.0.68\work\Catalina\localhost\Rites1\org\apache\jsp\Register_jsp.java]
The import com.sun.corba.se.spi.presentation.rmi.StubAdapter.request cannot be resolved
An error occurred at line: [14] in the generated java file: [C:\apache-tomcat-7.0.68\work\Catalina\localhost\Rites1\org\apache\jsp\Register_jsp.java]
Syntax error on token "(", . expected
An error occurred at line: [16] in the generated java file: [C:\apache-tomcat-7.0.68\work\Catalina\localhost\Rites1\org\apache\jsp\Register_jsp.java]
The import String cannot be resolved
An error occurred at line: [17] in the generated java file: [C:\apache-tomcat-7.0.68\work\Catalina\localhost\Rites1\org\apache\jsp\Register_jsp.java]
Syntax error on tokens, Name expected instead
**Stacktrace**:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:490)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:379)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.68 logs.
Apache Tomcat/7.0.68
我正在使用netbeans在maven项目中的一个名为Register.jsp的文件中构建一个注册表单
<%@page import="com.sun.corba.se.spi.presentation.rmi.StubAdapter.request(
Object, String, boolean)"%>
<%@page import="java.lang.ClassNotFoundException"%>
<%@page import="java.io.FileNotFoundException"%>
<%@page import="java.io.InputStream"%>
<%@page import="java.io.FileInputStream"%>
<%@page import="java.io.File"%>
<%@page import="javax.swing.JComboBox"%>
<%@page import="javax.swing.JTextField"%>
<%@page import="javax.swing.JRadioButton"%>
<%@page import="java.sql.*" %>
<%@page import="java.util.Date" %>
<% Class.forName("com.mysql.jdbc.Driver");%>
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" ></meta>
<link rel="stylesheet" type="text/css" href="CSS/RitesCSS.css"/>
<link rel="stylesheet" type="text/css" href="CSS/Resize.css" media="screen and (max-widht:1000px)"/>
<link rel="stylesheet" type="text/css" href="CSS/Menu.css"/>
<link rel="stylesheet" type="text/css" href="CSS/Layout.css"/>
<style type="text/css">
body{
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
}
</style>
<title>Register Now</title>
</head>
<body>
<%!
public class Followers {
String URL = "jdbc:mysql://localhost:3306/rites";
String USERNAME = "myusername";
String PASSWORD = "mypass";
Connection connection = null;
PreparedStatement insertUsers = null;
ResultSet resultSet = null;
public Followers() {
try {
connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
insertUsers = connection.prepareStatement(
"INSERT INTO followers (HajjID,UserName,ID,Phone,Country,Passport,Language,Gender,Photo,Password,State,DOB,adress)"
+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?);"
);
} catch (SQLException e) {
e.printStackTrace();
}
}
public int setFollowers(String HajjID, String UserName, String ID, String Phone, String country, String PassportNo, String Language, String rdoGender, String img, String txtPassword, String States, String DoB, String txtarAddress) {
int result = 0;
FileInputStream fis = null;
File Photo = new File("");
img = fis.toString();
try {
insertUsers.setString(1, HajjID);
insertUsers.setString(2, UserName);
insertUsers.setString(3, ID);
insertUsers.setString(4, Phone);
insertUsers.setString(5, country);
insertUsers.setString(6, PassportNo);
insertUsers.setString(7, Language);
insertUsers.setString(8, rdoGender);
try {
fis = new FileInputStream(Photo);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
insertUsers.setString(9, img);
insertUsers.setString(10, txtPassword);
insertUsers.setString(11, States);
insertUsers.setString(12, DoB);
insertUsers.setString(13, txtarAddress);
result = insertUsers.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
return result;
}
}
%>
<%
int result = 0;
if (request.getParameter("submit") != null) {
String Type = new String();
String HajjID = new String();
String UserName = new String();
String ID = new String();
String Phone = new String();
String country = new String();
String PassportNo = new String();
String Language = new String();
String rdoGender = new String();
String Photo = new String();
String txtPassword = new String();
String States = new String();
String DoB = new String();
String txtarAddress = new String();
if (request.getParameter("Type").toString() != null) {
Type = request.getParameter("Type").toString();
}
if (request.getParameter("HajjID").toString() != null) {
HajjID = request.getParameter("HajjID").toString();
}
if (request.getParameter("ID").toString() != null) {
ID = request.getParameter("ID").toString();
}
if (request.getParameter("Phone").toString() != null) {
Phone = request.getParameter("Phone").toString();
}
if (request.getParameter("country").toString() != null) {
country = request.getParameter("country").toString();
}
if (request.getParameter("PassportNo").toString() != null) {
PassportNo = request.getParameter("PassportNo").toString();
}
if (request.getParameter("Language").toString() != null) {
Language = request.getParameter("Language").toString();
}
if (request.getParameter("rdoGender").toString() != null) {
rdoGender = request.getParameter("rdoGender").toString();
}
if (request.getParameter("Photo").toString() != null) {
Photo = request.getParameter("Photo").toString();
}
if (request.getParameter("txtPassword").toString() != null) {
txtPassword = request.getParameter("txtPassword").toString();
}
if (request.getParameter("States").toString() != null) {
States = request.getParameter("States").toString();
}
if (request.getParameter("DoB").toString() != null) {
DoB = request.getParameter("DoB").toString();
}
if (request.getParameter("txtarAddress").toString() != null) {
txtarAddress = request.getParameter("txtarAddress").toString();
}
Followers users = new Followers();
result = users.setFollowers(HajjID, UserName, ID, Phone, country, PassportNo, Language, rdoGender, Photo, txtPassword, States, DoB, txtarAddress);
}
%>
<form id="form1" runat="server" action="register.php" method="POST">
<div id="contaner">
<div id="header">
<img src="logo.jpg" align="left"></img>
<h1> Rites</h1>
<li><a href="Register.jsp">Register now</a></li>
</div>
<div id="menu">
<ul>
<li><a href="index.jsp">Home</a></li>
<li><a href="about.jsp">About</a></li>
<li><a href="#">Rites</a></li>
<li><a href="#">Contact us</a></li>
<li><a href="login.jsp">Login</a></li>
</ul>
</div>
<div id="mainbody">
<div id="pageHeading"> <v>Registeration</v></div>
<div id="bodyLeft">
</div>
<div id="bodyRight"><h5>
<form name="registration" action="RegServlet" method="post" id="registerForm">
<table id="table1">
<tr>
<td>User name</td>
<td><input type="text" name="UserName" id="txt" class='StyleTxtField'/></td>
</tr>
<tr>
<td>ID</td>
<td><input type="text" name="ID" id="txt" class='StyleTxtField'/></td>
</tr>
<tr>
<td>Phone</td>
<td><input type="text" name="Phone" id="txt" class='StyleTxtField'/></td>
</tr>
<tr>
<td>Country</td>
<td><select name="country" id="txt" class='StyleSelectFiled'>
<option value="">Country...</option>
<option value="Afganistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
</select></td>
</tr>
<tr>
<td>Date of Birth</td>
<td>
<input type="date" name="DoB" id="txt" class='StyleTxtField'/>
</td>
</tr>
<tr>
<td>Address</td>
<td>
<textarea name="txtarAddress" id="txt" class='StyleTxtField'></textarea>
</td>
</tr>
<tr>
<td>Type</td>
<td><input type="radio" name="Type" id="Leader" value="Leader" ><label for="Leader">Leader</label>
<input type="radio" name="Type" id="Follower" value="Follower" onsubmit="setFollowers"><label for="Follower">Follower</label></td>
</tr>
<tr>
<td></td>
<input type="hidden" name="hidden" value="<%= result%>" />
<td><br><button type="reset" id="btm"><m>Reset</m></button>
<button type="submit" id="btm"><m>Register</m></button></td>
</tr>
</table><br>
</form></h5>
<SCRIPT language="JavaScript">
<!--
function dusplayResults()
{
if (document.myForm.hidden.value === 1) {
alert("Data Inserted1!");
}
}
</SCRIPT>
</div>
</div>
</div>
</form>
</body>
</html>
我想这样做“如果选择的名为”type“的单选按钮是跟随者将数据插入到跟随者表中,并且如果所选的名为”type“的单选按钮是领导者,则将数据插入到领导者表中”
我在phpmyadmine中使用名为rites的数据库
答案 0 :(得分:0)
<%@page import="com.sun.corba.se.spi.presentation.rmi.StubAdapter.request(
Object, String, boolean)"%>
导入错误。
使用
<%@ page import="static com.sun.corba.se.spi.presentation.rmi.StubAdapter.register" %>