Jsp获取Java的对象(JavaBean)
Java代码片段:
AuthReqBean authRep=new AuthReqBean();
authRep.setUserCode(usercode);
authRep.setReportType(reporttype);
authRep.setReportCode(reportcode)
request.setAttribute("authRep", authRep);
request.getRequestDispatcher("login.jsp").forward(request, response);
Jsp代码片段:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ page import="nc.xyzq.uuib.bean.AuthReqBean" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<base href="<%=basePath%>">
<title>正在跳转 ..</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="<%= path %>/scripts/jquery-1.7.2.min.js"></script>
<%
//String usercode = request.getParameter("usercode");//用request得到
AuthReqBean user=(AuthReqBean)request.getAttribute("authRep");
String usercode = user.getUserCode();
String reporttype = user.getReportType();
String reportcode = user.getReportCode();
%>
<script type="text/javascript">
function loginFR(){
var username = "<%=usercode%>";
var password = "<%=userpwd%>";
var reporttype = "<%=reporttype%>";
var reportcode = "<%=reportcode%>";
var scr = document.getElementById("ifr_frBI");
jQuery.ajax({
url:"http://"+serverip+":"+serverport+"/"+projectname+"/ReportServer?op=fs_load&cmd=sso",
dataType:"jsonp",
data:{"fr_username":username,"fr_password":password},
jsonp:"callback",
timeout:5000, success:function(data){
if(data.status == "success"){
if(urltype == "1"){
scr.src="http://"+serverip+":"+serverport+"/"+projectname+"/ReportServer?op=fr_bi&cmd=bi_init&id="+reportid+"&show=_bi_show_&createBy=-999";
}else if(urltype == "2"){
scr.src="http://"+serverip+":"+serverport+"/"+projectname+"/ReportServer?op=fs_main&cmd=entry_report&id="+reportid;
}else if(urltype == "3"){
scr.src="http://"+serverip+":"+serverport+"/"+projectname+"/ReportServer?reportlet="+reportid;
}
}else if (data.status == "fail"){
alert("fail!");
}
},
error:function(){
alert("单点登录出现失败");
}
});
//var scr = document.getElementById("ifr_fr");
//scr.src = "url";
} </script> <style>
#ifr_fr{
width: 84%;
height: 700px;
}
</style>
</head>
<body onload="loginFR()">
welcome to rzzx1. <input id="fbi_gjzxt" type="button" name="fbi_gjzxt" onclick="loginFR();" value ="<%=userpwd%>"/>
<iframe id="ifr_frBI" name="ifr_frBI" frameborder="0" src=""></iframe>
</body>
</html>