小妹初来乍道,望各位哥哥姐姐关照2

casesky 2003-06-13 10:51:57
谢谢大家,现在老问题解决了,可是又来了新问题。各位大哥能帮我看看下面的代码错在哪了吗?
小妹万分感谢!

package dd;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/

public class LoginServlet extends HttpServlet {
String[] words = {
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O",
"P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
//计算字符在数组中的位置
public int location(String tag) {
int I, location = 0;
for (I = 0; I < words.length; I++) {
if (words[I].equals(tag)) {
location = I + 1;
break;
}
}
return location;
}

//对密码加密
public String setpass(String pass, String temp_word) {
int I, J, location_pass, location_word, location;
String password = "";
for (I = 0; I < pass.length(); I++) {
location_pass = location(pass.substring(I, I + 1));
location_word = location(temp_word.substring(I, I + 1));
location = location % pass.length();
if (location >= 2) {
J = 1;
while (J < (61 / location)) {
password += words[location * J];
J++;
}
}
else
password += words[location];
}
if (password.length() > 100)
password = password.substring(0, 100);
return password;

}

public void doPost(HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException {
response.setContentType("text/html;charset=gb2312");
PrintWriter out = response.getWriter();
out.print("<title>用户登录</title>");
String user = request.getParameter = ("user");
String pass = request.getParameter = ("pass");
java.sql.Connection Conn;
java.sql.Statement Stmt;
java.sql.ResultSet Rst;

try {
//加载数据库驱动
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (java.lang.ClassNotFoundException e) {
out.print(e);
}
try {
//连结数据库
Conn = DriverManager.getConnection("jdbc:odbc:shop", "", "");
Stmt = Conn.createStatement();
//读取数据库
Rst = Stmt.executeQuery(
"select pass_word,user_level,temp_word from user_info where nick_name='" +
user + "'");
//判断用户名是否正确
if (!Rst.next())
out.println("没有此用户名!");

else {
String pass_word = Rst.getString("pass_word");
String user_level = Rst.getString("user_level");
String temp_word = Rst.getString("temp_word");
//判断密码是否正确
if (pass.length() != temp_word.length())
out.println("密码错误!");

else {
pass = setpass(pass, temp_word);
if (!pass_word.equals(pass))
out.println("密码错误!");

else {
//设置session
HttpSession session = request.getSession(true);
session.setAttribute("user_name", user);
session.setAttribute("user_have_login_yes", "yes");
session.setAttribute("user_login_level", user_level);
//跳之首页
response.sendRedirect("/");
}
}
}
Rst.close();
Stmt.close();
Conn.close();
}
catch (SQLException ex) {
out.println(ex);
out.close();
}
}
}


错误如下:

"LoginServlet.java": Error #: 300 : variable getParameter not found in interface javax.servlet.http.HttpServletRequest at line 66, column 27
"LoginServlet.java": Error #: 300 : variable getParameter not found in interface javax.servlet.http.HttpServletRequest at line 67, column 27


望各位兄台不吝赐教!小妹感激不尽!另外还有一个,差不多同样的错误啊!我怎么老是
受打击啊!

package dd;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/

public class LogoutServlet extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException {
//建立session对象
HttpSession session=request.getSession(true);
//清除session对象
session.removeAttribute=("user_name");
session.removeAttribute=("user_have_login_yes");
session.removeAttribute=("user_login_level");
response.sendRedirect("/");
}
}

错误如下:
"LogoutServlet.java": Error #: 300 : variable removeAttribute not found in interface javax.servlet.http.HttpSession at line 22, column 11
"LogoutServlet.java": Error #: 300 : variable removeAttribute not found in interface javax.servlet.http.HttpSession at line 23, column 11
"LogoutServlet.java": Error #: 300 : variable removeAttribute not found in interface javax.servlet.http.HttpSession at line 24, column 11
...全文
64 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
baliok 2003-06-20
  • 打赏
  • 举报
回复
以后有问题要多想想,不用急着问。
Luckyfeeling 2003-06-20
  • 打赏
  • 举报
回复
你他妈死去吧
有问题就问
整天见你称小妹妹
难道论坛就你一个母的
即便是,有什么娇嫩的
难道靠色相获取帮助..........
KevinChu 2003-06-20
  • 打赏
  • 举报
回复
把标题改为“散分”吧。。。
lhlemail 2003-06-20
  • 打赏
  • 举报
回复
总结一下!
wswhp 2003-06-13
  • 打赏
  • 举报
回复
up
casesky 2003-06-13
  • 打赏
  • 举报
回复
不好意思,我现在都解决了!再次致意!

51,408

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧