JSP网站登录记忆跳转实现的一种方法
member.jsp //session限制访问页
<%
String url = ""
if(session.getAttribute("username")==null)
{
url = myRedirect.dealurl(request);//记录当前地址和请求参数,dealurl将实际url处理了避免和要请求url有干扰,因为会有& 字符
response.sendRedirect("weblogin.jsp?url="+url) ;//重定向到登录页面
}
%>
------------------------------------------------
weblogin.jsp
<%
String url = request.getParameter("url");
String userid =request.getParameter("userid");
String password =request.getParameter("password");
if(userid!=null) //如果是登录提交执行下面代码
{
if(登录成功)
{
session.setAttribute("userid",userid);
out.println("<script>alert('登录成功,谢谢光临');self.location.href='"+myRedirect.geturl(url)+"';</script>");//转向到首次请求的url,.geturl(url)是把转化过的地址转化回来变成真实url.
}else{
out.println("<script>alert('用户名或密码错误');history.back();</script>");
}
}else{//如果不是登录提交显示现面登录界面
%>
<table width="311" height="162" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="311" height="162" align="center"> 您还没有登录,请先登录<br>
<table width="155" border="0" cellpadding="0" cellspacing="5" class="font12">
<form name="loginfrm" action="weblogin.jsp" method="post" id="loginfrm" onSubmit="return checkfrm();">
<tr>
<td width="41" height="33" valign="bottom">帐 号:</td>
<td width="99" valign="bottom"><input name="user
相关文档:
4.1 表单数据概述
如果你曾经使用过Web搜索引擎,或者浏览过在线书店、股票价格、机票信息,或许会留意到一些古怪的URL,比如“http://host/path?user=Marty+Hall&origin=bwi&dest=lax”。这个URL中位于问号后面的部分,即“user=Marty+Hall&origin=bwi&dest=lax”,就是表单数 ......
index.jsp:
<html>
<head>
<title>The News</title>
</head>
<body>
<h1> Latest News</h1>
<table>
<tr>
<td><h3><%@include file="items/news1.jsp" %></h3></td>
</tr>
<tr>
<td> ......
注释
在客户端显示一个注释.
JSP 语法
<!-- comment [ <%= expression %> ] -->
例子 1
<!-- This file displays the user login screen -->
在客户端的HTML源代码中产生和上面一样的数据:
<!-- This file displays the user login screen -->
例子 2
<!-- This page was lo ......
在编写JSP程序时,常常会碰到中文字符处理的问题,在接受request的中文字符时显示出来一串乱码。网上处理方法一箩筐,下面说说我用过的两种有效地解决办法:
1.为程序编写一个字符串处理函数,用一个静态文件保存,在需要处理中文字符的JSP页面中包含它,
<%!
public String codeToString(String str)
{ ......
我们使用Google提供的iframe让jsp页面嵌入到flex中
首先,请到http://code.google.com/p/flex-iframe/下载iframe 的swc包
第二步,把swc包放入flex_libs中,如果不是web项目就放入lib下
第三步,创建一个mxml文件
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/ ......