modifypassword.java
来自「网上银行EJB版本」· Java 代码 · 共 44 行
JAVA
44 行
package mypackage;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.naming.NamingException;
public class ModifyPassword extends HttpServlet
{
private static final String CONTENT_TYPE = "text/html; charset=GBK";
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String accounts = (String)request.getSession().getAttribute("accounts");
String password = request.getParameter("password");
int success = 0;
try{
Context context = new InitialContext();
TaskHome taskHome = (TaskHome)PortableRemoteObject.narrow(context.lookup("Task"), TaskHome.class);
Task task;
task = taskHome.create();
success = task.modifyPassword(accounts, password);
}
catch(Throwable ex){
ex.printStackTrace();
}
if(success == 1){
request.getSession().getServletContext().getRequestDispatcher("/modifysuccess.jsp").forward(request, response);
request.getSession().removeAttribute("chn");
request.getSession().removeAttribute("accounts");
}
else
request.getSession().getServletContext().getRequestDispatcher("/modifyfail.jsp").forward(request, response);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?