jsp到serlet传值的问题
本帖最后由 fatso1984 于 2013-08-09 16:21:53 编辑 jsp代码:
<form action="<%=path%>/Index">
<c:set var="qqq" value="123" scope="page"></c:set>
<%
request.setAttribute("temp1","456") ;
%>
<input type="submit" value="111">
</form>
System.out.println(request.getAttribute("qqq"));
System.out.println(request.getAttribute("temp1"));
<form method="post" name="unform" action="<%=basePath%>LoginServlet" target="_parent">
<table border="0" width="61%" style="background-color:#888fff" bgcolor="#888fff" >
<td width="80%" class="3dfont"><font color="#008040"></font>
<table border="0" width="100%" bgcolor="#888fff" >
<input type="hidden" id="info" value="${param.info}">
<tr >
<td width="10%" class="3dfont"><b>账户</b></td>
<td width="20%"><input type="text" name="username" value="bcsflilong"/></td>
<td width="10%" class="3dfont"><b>密码</b></td>
<td width="20%"><input type="password" name="psw" value="" /></td>
<td width="20%"><input type="submit" onClick="return _submit()" value="登录"> </td>
</tr></b>
</table></td></table></center>
</form>
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session=request.getSession();
String username=request.getParameter("username");
String psw=request.getParameter("psw");
userVO user=new userVO();
user.setUse_loginname(username);
user.setUse_password(psw);
try {
user=new LoginService().login(user);
if (user!=null) {
session.setAttribute("loginuser",user);
}else {
response.sendRedirect("main/login.jsp?info=no");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}