谁能帮我解读一段JSP代码?所有我在后面打//的一排,麻烦高手解读一下什么意思。
另外,我这个是同另外一个JSP页面和servlet一起的,但是运行时出错,JSP页面肯定是好的没问题,所以也想请大家帮我看看是不是这个里面的问题。(此处省略若干个impo...
另外,我这个是同另外一个JSP页面和servlet一起的,但是运行时出错,JSP页面肯定是好的没问题,所以也想请大家帮我看看是不是这个里面的问题。
(此处省略若干个import语句,因为字数打不下)
public class MVC1 extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
register rr = new register();
HttpSession ss = request.getSession(true); //尤其是true代表什么
ss.setAttribute("bean", rr); //尤其是bean代表什么
String s1 = request.getParameter("name");
String s2 = request.getParameter("password1");
String s3 = request.getParameter("password2");
String s4 = request.getParameter("connection");
String s5 = request.getParameter("address");
int id ;
if(s2.equals(s3))
{
try
{
Statement sta = dbconnection.getcon().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); //
ResultSet rs = sta.executeQuery("select * from users");
rs.last();
id = rs.getInt(1)+1;
PreparedStatement ps = dbconnection.getcon().prepareStatement("insert into users values(?,?,?,?,?)");
String news1 = new String(s1.getBytes("gb2312"));
出于字数限制,后面的内容在问题补充里
ps.setInt(1, id);
ps.setString(2, news1);
ps.setString(3, s2);
ps.setString(4, s4);
ps.setString(5, s5);
ps.executeUpdate();//
rr.setId(id);//
rr.setName(news1);
rr.setFlag(true);
ss.setAttribute("bo", true);//
}
后面还有一个catch(Exception e)和一个else方法还有两句话,这里打不下了,不过那几句应该都没有问题。 展开
(此处省略若干个import语句,因为字数打不下)
public class MVC1 extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
register rr = new register();
HttpSession ss = request.getSession(true); //尤其是true代表什么
ss.setAttribute("bean", rr); //尤其是bean代表什么
String s1 = request.getParameter("name");
String s2 = request.getParameter("password1");
String s3 = request.getParameter("password2");
String s4 = request.getParameter("connection");
String s5 = request.getParameter("address");
int id ;
if(s2.equals(s3))
{
try
{
Statement sta = dbconnection.getcon().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); //
ResultSet rs = sta.executeQuery("select * from users");
rs.last();
id = rs.getInt(1)+1;
PreparedStatement ps = dbconnection.getcon().prepareStatement("insert into users values(?,?,?,?,?)");
String news1 = new String(s1.getBytes("gb2312"));
出于字数限制,后面的内容在问题补充里
ps.setInt(1, id);
ps.setString(2, news1);
ps.setString(3, s2);
ps.setString(4, s4);
ps.setString(5, s5);
ps.executeUpdate();//
rr.setId(id);//
rr.setName(news1);
rr.setFlag(true);
ss.setAttribute("bo", true);//
}
后面还有一个catch(Exception e)和一个else方法还有两句话,这里打不下了,不过那几句应该都没有问题。 展开
2个回答
展开全部
public class MVC1 extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
register rr = new register();
HttpSession ss = request.getSession(true); //尤其是true代表什么
ss.setAttribute("bean", rr); //尤其是bean代表什么
String s1 = request.getParameter("name");
String s2 = request.getParameter("password1");
String s3 = request.getParameter("password2");
String s4 = request.getParameter("connection");
String s5 = request.getParameter("address");
int id ;
if(s2.equals(s3))
{
try
{
Statement sta = dbconnection.getcon().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); //
ResultSet rs = sta.executeQuery("select * from users");
rs.last();
id = rs.getInt(1)+1;
PreparedStatement ps = dbconnection.getcon().prepareStatement("insert into users values(?,?,?,?,?)");
String news1 = new String(s1.getBytes("gb2312"));
出于字数限制,后面的内容在问题补充里
ps.setInt(1, id);
ps.setString(2, news1);
ps.setString(3, s2);
ps.setString(4, s4);
ps.setString(5, s5);
ps.executeUpdate();//
rr.setId(id);//
rr.setName(news1);
rr.setFlag(true);
ss.setAttribute("bo", true);//
}
后面还有一个catch(Exception e)和一个else方法还有两句话,这里打不下了,不过那几句应该都没有问题。
我有更好的答案
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
register rr = new register();
HttpSession ss = request.getSession(true); //尤其是true代表什么
ss.setAttribute("bean", rr); //尤其是bean代表什么
String s1 = request.getParameter("name");
String s2 = request.getParameter("password1");
String s3 = request.getParameter("password2");
String s4 = request.getParameter("connection");
String s5 = request.getParameter("address");
int id ;
if(s2.equals(s3))
{
try
{
Statement sta = dbconnection.getcon().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); //
ResultSet rs = sta.executeQuery("select * from users");
rs.last();
id = rs.getInt(1)+1;
PreparedStatement ps = dbconnection.getcon().prepareStatement("insert into users values(?,?,?,?,?)");
String news1 = new String(s1.getBytes("gb2312"));
出于字数限制,后面的内容在问题补充里
ps.setInt(1, id);
ps.setString(2, news1);
ps.setString(3, s2);
ps.setString(4, s4);
ps.setString(5, s5);
ps.executeUpdate();//
rr.setId(id);//
rr.setName(news1);
rr.setFlag(true);
ss.setAttribute("bo", true);//
}
后面还有一个catch(Exception e)和一个else方法还有两句话,这里打不下了,不过那几句应该都没有问题。
我有更好的答案
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询