请教大家,我这段程序语法错误较多,第一行有Syntax error on token(s), misplaced construct(s)这个错误,我该怎么解决呢
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
public class rregisterServlet extends HttpServlet {
Connection connection;
public void init() throws ServletException {
} public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
} public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 获得个人注册信息并存入对应的字符串变量中
String name = new String(request.getParameter("follower_name").getBytes("8859_1"));
String message = new String(request.getParameter("follower_message").getBytes("8859_1"));
String sql_info = "insert into follow_info(follower_name, follower_message) values ('" + follower_name + "', '" + follower_message + "')";
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter(); ///// <%@ page contentType="text/html;charset=gb2312"%>
//<%
//变量声明
java.sql.Connection sqlCon; //数据库连接对象
java.sql.Statement sqlStmt; //SQL语句对象
java.sql.ResultSet sqlRst; //结果集对象
java.lang.String strCon; //数据库连接字符串
java.lang.String strSQL; //SQL语句
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
java.lang.String strPage;
int i,j,k; //设置一页显示的记录数
intPageSize = 12; //取得待显示页码
strPage = request.getParameter("page");
if(strPage==null){
//表明在QueryString中没有page这一个参数,此时显示第一页数据
intPage = 1;
} else{
//将字符串转换成整型
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1; }
String url="jdbc:mysql://localhost:3306/blar_world?useUnicode=true&characterEncoding=utf-8";
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn=DriverManager.getConnection(url, "root", "root");
//创建SQL语句对象
sqlStmt = sqlCon.createStatement();
//获取记录总数
strSQL = "select count(*) from 用户信息";
sqlRst = sqlStmt.executeQuery(strSQL);
//执行SQL语句并取得结果集
sqlRst.next(); //记录集刚打开的时候,指针位于第一条记录之前
intRowCount = sqlRst.getInt(1);
sqlRst.close(); //关闭结果集
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//调整待显示的页码 if(intPage>intPageCount) intPage = intPageCount;
//设置获取数据SQL语句
strSQL = "select follower_name,follower_message,followee_name,followee_message,chat_name,chat_message, from follower,followee,chat_group ORDER BY id DESC";//执行SQL语句并取得结果集
sqlRst = sqlStmt.executeQuery(strSQL);
//将记录指针定位到待显示页的第一条记录上
i = (intPage-1) * intPageSize;
for(j=0;j<i;j++) sqlRst.next(); %>
out.println("
<html>
<head>
<title>
This is the following info...
</title>
<style type=\"text/css\">
ul{ list-style-type:none }
body {
width:1010px ;
height: 720px;
background-repeat:no-repeat;
background: #EBEBEB url('F:\Documents and Settings\Administrator\桌面\999.jpg') fixed top left;} p {font: WST_Germ ;font-size:20px ; background-color:blue; padding:0px; }
</style>
</head>
<body>
<table>
<tr>
<td>
<%
//显示数据
i = 0;
while(i<intPageSize && sqlRst.next()){ %>
<ul>
<li bgcolor=#336699>
~~~留言~~~
</li>
<br>
<br>
<li>
用户名:<%=sqlRst.getString("follower_name")%>
</li>
<br>
<br>
<li>
内容:<%=sqlRst.getString("follower_message")%>
</li><br>
<br>
<br>
<% i++; } %><li colspan=2 align=center>
第<%=intPage%>页 共<%=intPageCount%>页
<%if(intPage<intPageCount){%>
<a href=\"ly3.jsp?page=<%=intPage+1%>\">下一页</a><%
}
%>
<%if(intPage>1){%>
<a href=\"ly3.jsp?page=<%=intPage-1%>\">上一页</a><%
}
%>
</li>
</ul>
<ul >
<li >
<div>
<li><img src=\"F:\Documents and Settings\Administrator\桌面\hua1.jpg\">你好!欢迎跟踪你大爷我...
</li>
<br>
<br>
<li class=\"info\">
<textarea cols=\"40%\" rows=\"3\" id=\"status\" name=\"status\" accesskey=\"u\" autocomplete=\"off\" tabindex=\"1\" style=\"background-color:green;color:#yellow;\" ></textarea>
<input type=\"submit\" name=\"update\" value=\"交谈\" id=\"update-submit\" class=\"status-btn round-btn\" tabindex=\"2\" />
</li>
<br>
<br>
<li>
<input type=\"submit\" name=\"update\" value=\"返回\" id=\"update-submit\" class=\"status-btn round-btn\" tabindex=\"2\" onclick=\"message.html\"/>
<input type=\"submit\" name=\"update\" value=\"退出\" id=\"update-submit\" class=\"status-btn round-btn\" tabindex=\"2\" onclick=\"loginin.html\"/>
</li>
</div>
</ul>
</td>
<br>
<br>
</td><td align=\"left\" background=\"F:\Documents and Settings\Administrator\桌面\888.jpg\" width=\"200\" background-repeat=\"no-repeat\">
<ul>
<li>
<p>这些是发信息想和我交谈的人</p>
</li>
<li><div style=\"background-color:#cc2000; width:45px;height:30px\ "><img src=\"F:\Documents and Settings\Administrator\桌面\555.jpg\" width=\"45\" height=\"29\"></div> <div font-size:200px >khjhjhjhjhjhjhkhjhj khjhjhjhjhjhkhjhj </div></li>
<br>
<li bgcolor=#336699>
~~~留言~~~
</li>
<br>
<br>
<li>
用户名:<%=sqlRst.getString(\"chat_name\")%>
</li>
<br>
<br>
<li>
内容:<%=sqlRst.getString(\"chat_message\")%>
</li><br>
<br>
<br>
<% i++; } %><li colspan=2 align=center>
第<%=intPage%>页 共<%=intPageCount%>页
<%if(intPage<intPageCount){%>
<a href=\"ly3.jsp?page=<%=intPage+1%>\">下一页</a><%
}
%>
<%if(intPage>1){%>
<a href=\"ly3.jsp?page=<%=intPage-1%>\">上一页</a><%
}
%>
</li> </ul>
<td align=\"left\" bordercolor=\"#ffffff\" background=\"F:\Documents and Settings\Administrator\桌面\777.jpg\"BGCOLOR=\" \" width="200" height=\"700\" cellpadding=\"10px\">
<ul>
<li margin:10px line-height : 100% background-color=\"yellow\" border: 1px solid #cc3300 >
<p>这些是等着follow我的人</p>
</li>
<li>
<div style=\"background-color:#cc2000; width:45px;height:30px \"><img src=\"F:\Documents and Settings\Administrator\桌面\444.jpg\" width=\"45\" height=\"29\"></div> <div font-size:200px >khjhjhjhjhjhjhkhjhj khjhjhjhjhjhkhjhj </div></li>
<br>
<li bgcolor=#336699>
~~~留言~~~
</li>
<br>
<br>
<li>
用户名:<%=sqlRst.getString(\"followee_name\")%>
</li>
<br>
<br>
<li>
内容:<%=sqlRst.getString(\"followee_message\")%>
</li><br>
<br>
<br>
<% i++; } %><li colspan=2 align=center>
第<%=intPage%>页 共<%=intPageCount%>页
<%if(intPage<intPageCount){%>
<a href=\"ly3.jsp?page=<%=intPage+1%>\">下一页</a><%
}
%>
<%if(intPage>1){%>
<a href=\"ly3.jsp?page=<%=intPage-1%>\">上一页</a><%
}
%>
</li> </ul>
</td>
</tr>
</table>
</body>
</html>");
<%
public boolean addRecord( String sql_info) // 添加记录函数
{
boolean made = false;
try {
String url="jdbc:mysql://localhost:3306/blar_world?useUnicode=true&characterEncoding=utf-8";
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection=DriverManager.getConnection(url, "root", "root");
statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
statement.executeUpdate(sql_info); // 向userinfo表中插入数据
statement.close(); // 关闭statement对象
made = true;
}
catch(Exception ex) // 异常处理
{
ex.printStackTrace();
}
return made;
}
}
//关闭结果集sqlRst.close();//关闭SQL语句对象sqlStmt.close();//关闭数据库sqlCon.close();%>
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
public class rregisterServlet extends HttpServlet {
Connection connection;
public void init() throws ServletException {
} public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
} public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 获得个人注册信息并存入对应的字符串变量中
String name = new String(request.getParameter("follower_name").getBytes("8859_1"));
String message = new String(request.getParameter("follower_message").getBytes("8859_1"));
String sql_info = "insert into follow_info(follower_name, follower_message) values ('" + follower_name + "', '" + follower_message + "')";
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter(); ///// <%@ page contentType="text/html;charset=gb2312"%>
//<%
//变量声明
java.sql.Connection sqlCon; //数据库连接对象
java.sql.Statement sqlStmt; //SQL语句对象
java.sql.ResultSet sqlRst; //结果集对象
java.lang.String strCon; //数据库连接字符串
java.lang.String strSQL; //SQL语句
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
java.lang.String strPage;
int i,j,k; //设置一页显示的记录数
intPageSize = 12; //取得待显示页码
strPage = request.getParameter("page");
if(strPage==null){
//表明在QueryString中没有page这一个参数,此时显示第一页数据
intPage = 1;
} else{
//将字符串转换成整型
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1; }
String url="jdbc:mysql://localhost:3306/blar_world?useUnicode=true&characterEncoding=utf-8";
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn=DriverManager.getConnection(url, "root", "root");
//创建SQL语句对象
sqlStmt = sqlCon.createStatement();
//获取记录总数
strSQL = "select count(*) from 用户信息";
sqlRst = sqlStmt.executeQuery(strSQL);
//执行SQL语句并取得结果集
sqlRst.next(); //记录集刚打开的时候,指针位于第一条记录之前
intRowCount = sqlRst.getInt(1);
sqlRst.close(); //关闭结果集
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//调整待显示的页码 if(intPage>intPageCount) intPage = intPageCount;
//设置获取数据SQL语句
strSQL = "select follower_name,follower_message,followee_name,followee_message,chat_name,chat_message, from follower,followee,chat_group ORDER BY id DESC";//执行SQL语句并取得结果集
sqlRst = sqlStmt.executeQuery(strSQL);
//将记录指针定位到待显示页的第一条记录上
i = (intPage-1) * intPageSize;
for(j=0;j<i;j++) sqlRst.next(); %>
out.println("
<html>
<head>
<title>
This is the following info...
</title>
<style type=\"text/css\">
ul{ list-style-type:none }
body {
width:1010px ;
height: 720px;
background-repeat:no-repeat;
background: #EBEBEB url('F:\Documents and Settings\Administrator\桌面\999.jpg') fixed top left;} p {font: WST_Germ ;font-size:20px ; background-color:blue; padding:0px; }
</style>
</head>
<body>
<table>
<tr>
<td>
<%
//显示数据
i = 0;
while(i<intPageSize && sqlRst.next()){ %>
<ul>
<li bgcolor=#336699>
~~~留言~~~
</li>
<br>
<br>
<li>
用户名:<%=sqlRst.getString("follower_name")%>
</li>
<br>
<br>
<li>
内容:<%=sqlRst.getString("follower_message")%>
</li><br>
<br>
<br>
<% i++; } %><li colspan=2 align=center>
第<%=intPage%>页 共<%=intPageCount%>页
<%if(intPage<intPageCount){%>
<a href=\"ly3.jsp?page=<%=intPage+1%>\">下一页</a><%
}
%>
<%if(intPage>1){%>
<a href=\"ly3.jsp?page=<%=intPage-1%>\">上一页</a><%
}
%>
</li>
</ul>
<ul >
<li >
<div>
<li><img src=\"F:\Documents and Settings\Administrator\桌面\hua1.jpg\">你好!欢迎跟踪你大爷我...
</li>
<br>
<br>
<li class=\"info\">
<textarea cols=\"40%\" rows=\"3\" id=\"status\" name=\"status\" accesskey=\"u\" autocomplete=\"off\" tabindex=\"1\" style=\"background-color:green;color:#yellow;\" ></textarea>
<input type=\"submit\" name=\"update\" value=\"交谈\" id=\"update-submit\" class=\"status-btn round-btn\" tabindex=\"2\" />
</li>
<br>
<br>
<li>
<input type=\"submit\" name=\"update\" value=\"返回\" id=\"update-submit\" class=\"status-btn round-btn\" tabindex=\"2\" onclick=\"message.html\"/>
<input type=\"submit\" name=\"update\" value=\"退出\" id=\"update-submit\" class=\"status-btn round-btn\" tabindex=\"2\" onclick=\"loginin.html\"/>
</li>
</div>
</ul>
</td>
<br>
<br>
</td><td align=\"left\" background=\"F:\Documents and Settings\Administrator\桌面\888.jpg\" width=\"200\" background-repeat=\"no-repeat\">
<ul>
<li>
<p>这些是发信息想和我交谈的人</p>
</li>
<li><div style=\"background-color:#cc2000; width:45px;height:30px\ "><img src=\"F:\Documents and Settings\Administrator\桌面\555.jpg\" width=\"45\" height=\"29\"></div> <div font-size:200px >khjhjhjhjhjhjhkhjhj khjhjhjhjhjhkhjhj </div></li>
<br>
<li bgcolor=#336699>
~~~留言~~~
</li>
<br>
<br>
<li>
用户名:<%=sqlRst.getString(\"chat_name\")%>
</li>
<br>
<br>
<li>
内容:<%=sqlRst.getString(\"chat_message\")%>
</li><br>
<br>
<br>
<% i++; } %><li colspan=2 align=center>
第<%=intPage%>页 共<%=intPageCount%>页
<%if(intPage<intPageCount){%>
<a href=\"ly3.jsp?page=<%=intPage+1%>\">下一页</a><%
}
%>
<%if(intPage>1){%>
<a href=\"ly3.jsp?page=<%=intPage-1%>\">上一页</a><%
}
%>
</li> </ul>
<td align=\"left\" bordercolor=\"#ffffff\" background=\"F:\Documents and Settings\Administrator\桌面\777.jpg\"BGCOLOR=\" \" width="200" height=\"700\" cellpadding=\"10px\">
<ul>
<li margin:10px line-height : 100% background-color=\"yellow\" border: 1px solid #cc3300 >
<p>这些是等着follow我的人</p>
</li>
<li>
<div style=\"background-color:#cc2000; width:45px;height:30px \"><img src=\"F:\Documents and Settings\Administrator\桌面\444.jpg\" width=\"45\" height=\"29\"></div> <div font-size:200px >khjhjhjhjhjhjhkhjhj khjhjhjhjhjhkhjhj </div></li>
<br>
<li bgcolor=#336699>
~~~留言~~~
</li>
<br>
<br>
<li>
用户名:<%=sqlRst.getString(\"followee_name\")%>
</li>
<br>
<br>
<li>
内容:<%=sqlRst.getString(\"followee_message\")%>
</li><br>
<br>
<br>
<% i++; } %><li colspan=2 align=center>
第<%=intPage%>页 共<%=intPageCount%>页
<%if(intPage<intPageCount){%>
<a href=\"ly3.jsp?page=<%=intPage+1%>\">下一页</a><%
}
%>
<%if(intPage>1){%>
<a href=\"ly3.jsp?page=<%=intPage-1%>\">上一页</a><%
}
%>
</li> </ul>
</td>
</tr>
</table>
</body>
</html>");
<%
public boolean addRecord( String sql_info) // 添加记录函数
{
boolean made = false;
try {
String url="jdbc:mysql://localhost:3306/blar_world?useUnicode=true&characterEncoding=utf-8";
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection=DriverManager.getConnection(url, "root", "root");
statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
statement.executeUpdate(sql_info); // 向userinfo表中插入数据
statement.close(); // 关闭statement对象
made = true;
}
catch(Exception ex) // 异常处理
{
ex.printStackTrace();
}
return made;
}
}
//关闭结果集sqlRst.close();//关闭SQL语句对象sqlStmt.close();//关闭数据库sqlCon.close();%>
解决方案 »
- 求Upload文件上传如何控制文件选择路径?解决方法越EASY越GOOD
- 求java Web开发新技术
- 谁有格式化代码的插件?
- Jsp中的图片从Tomcat移植到WebLogic中显示问题
- 求助,jsp,大家帮帮忙
- 过滤非法汉字
- struts奇怪的问题
- jsp bean不能访问的问题
- 同一个版本的JBuilder为什么一行一个会报错?????????????????????????????????????
- 我想問下csdn呢個網站入面某d網頁個果"打印文章"功能是點樣做的?因為我睇佢個果網頁的源碼是在javascript入面調用一個function,就噤簡單?
- struts-config.xml 必须放在 WEB-INF下吗,放在src目录下怎么读取
- 有招Java-Web的公司吗?
strSQL = "select follower_name,follower_message,followee_name,followee_message,chat_name,chat_message, from follower,followee,chat_group ORDER BY id DESC";
你这一句查询字段的时候要为各个表制定别名,不然你哪知道查询的字段属于哪个表啊。
Multiple ers at this line
- Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
- Syntax error, type parameters are only available if source level is
5.0if (success){
out.println("<html><head><title>This is the following info...</title><style type=\"text/css\">ul{ list-style-type:none } body {width:1010px ;height: 720px; background-repeat:no-repeat;background: #EBEBEB url('F:\\Documents and Settings\Administrator\\桌面\\999.jpg')fixed top left;} p {font: WST_Germ ;font-size:20px ; background-color:blue; padding:0px; } </style></head><body>");
if (rs.next()){
out.println("<table><tr><td><ul><li bgcolor=#336699>~~~留言~~~</li><br><br><li>用户名:<%=sqlRst.getString(\"follower_name\")%></li>");
out.println("<br><br><li>内容:<%=sqlRst.getString(\"follower_message\")%></li><br><br><br></ul><ul><div><li><img src=\"F:\\Documents and Settings\\Administrator\\桌面\\hua1.jpg\">你好!欢迎跟踪你大爷我...");
out.println("</li><br><br><li class=\"info\"><textarea cols=\"40%\" rows=\"3\" id=\"status\" name=\"status\" accesskey=\"u\" autocomplete=\"off\" tabindex=\"1\" style=\"background-color:green;color:#yellow;\"></textarea>");
out.println("<input type=\"submit\" name=\"update\" value=\"交谈\" id=\"update-submit\" class=\"status-btn round-btn\" tabindex=\"2\" />");
out.println("</li><br><br><li><input type=\"submit\" name=\"update\" value=\"返回\" id=\"update-submit\" class=\"status-btn round-btn\" tabindex=\"2\" onclick=\"message.html\"/><input type=\"submit\" name=\"update\" value=\"退出\" id=\"update-submit\" class=\"status-btn round-btn\" tabindex=\"2\" onclick=\"loginin.html\"/>");
out.println("</li></div></ul></td><br><br></td><td align=\"left\" background=\"F:\\Documents and Settings\\Administrator\\桌面\\888.jpg\" width=\"200\" background-repeat=\"no-repeat\"><ul>");
out.println("<li><p>这些是发信息想和我交谈的人</p></li><li><div style=\"background-color:#cc2000; width:45px;height:30px \"><img src=\"F:\\Documents and Settings\\Administrator\\桌面\\555.jpg\" width=\"45\" height=\"29\"></div> <div font-size:200px >khjhjhjhjhjhjhkhjhj khjhjhjhjhjhkhjhj </div></li><br>");
out.println("<li bgcolor=#336699>~~~留言~~~</li><br><br><li>用户名:<%=sqlRst.getString(\"chat_name\")%></li><br><br><li>内容:<%=sqlRst.getString(\"chat_message\")%></li><br><br><br>");
out.println("</li></ul></td><td align=\"left\" bordercolor=\"#ffffff\" background=\"F:\\Documents and Settings\\Administrator\\桌面\\777.jpg\"BGCOLOR=\" \" width=\"200\" height=\"700\" cellpadding=\"10px\">");
out.println("<ul><li margin:10px line-height : 100% background-color=\"yellow\" border: 1px solid #cc3300 ><p>这些是等着follow我的人</p></li><li><div style=\"background-color:#cc2000; width:45px;height:30px \"><img src=\"F:\\Documents and Settings\\Administrator\\桌面\\444.jpg\" width=\"45\" height=\"29\"></div> <div font-size:200px >khjhjhjhjhjhjhkhjhj khjhjhjhjhjhkhjhj </div></li>");
out.println("<br><li bgcolor=#336699>~~~留言~~~</li><br><br><li>用户名:<%=sqlRst.getString(\"followee_name\")%></li><br><br><li>内容:<%=sqlRst.getString(\"followee_message\")%></li>");
out.println("<br><br><br></ul></td></tr></table></body></html>");
}else{
out.println("数据库里面没数据,你看着办吧");
out.println("</body></html>");
}