JSP获取屏幕分辨率,就是JSP获取JS中的变量问题,急》》》》》》》》
要求:就这一个JSP页面,其中的JAVA代码需要传分辨率。不要借助其他中间件。
目前来说只能用隐藏域或者提交到本界面。我这方面不精通,麻烦会的给个版本。代码。。。3KS!!
<%@ page contentType="text/html;charset=GBK" language="java" %>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%
String host = (String) session.getAttribute("ssohost");
String port = (String) session.getAttribute("ssoport");
String loginName = (String) session.getAttribute("ssoaccount");
String password = (String) session.getAttribute("ssopass");
String ssosuburl = (String) session.getAttribute("ssosuburl");
String ssoprotocol = (String) session.getAttribute("ssoprotocol");
session.removeAttribute("ssohost");
session.removeAttribute("ssoport");
session.removeAttribute("ssoaccount");
session.removeAttribute("ssopass");
session.removeAttribute("ssosuburl");
session.removeAttribute("ssoprotocol");
java.lang.String sKey = new java.util.Date().getTime()+"";
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
String workDate=format.format(new Date());
java.lang.String sURL = "http://X.X.X.X/service/JKYNCLoginServlet?key="+sKey+"&language=simpchn&usercode="+loginName+"&accountcode=001&pkcorp=0001&width=1280&height=1024"; //这里需要传动态获取的分辨率
java.net.URL l_url = new java.net.URL(sURL);
java.net.HttpURLConnection l_connection = (java.net.HttpURLConnection) l_url.openConnection();
l_connection.connect();
java.io.InputStream l_urlStream = l_connection.getInputStream();
java.io.BufferedReader l_reader = new java.io.BufferedReader(new java.io.InputStreamReader(l_urlStream));
java.lang.String sCurrentLine = "";
java.lang.String sTotalString = "";
while ((sCurrentLine = l_reader.readLine()) != null)
{
sTotalString+=sCurrentLine;
}
%>
<script>
var _url = "http://X.X.X.X/loginIT.jsp?key=<%=sKey%>";
setTimeout(function(){window.location.href=_url;}, 3000);
</script>
------解决方案--------------------<script>
var _url = "http://X.X.X.X/loginIT.jsp?key=<%=sKey%>";
setTimeout(function(){window.location.href=_url;}, 3000);
</script>
<%
String sKey=request.getParameter("key");
%>
------解决方案--------------------呵呵 还是不太清楚你的要求,,是想jsp获取js值,还是把js值怎么传到jsp去?
------解决方案--------------------如果是jsp获取js值的话只能传到本页面,重新加载了, 因为jsp中java语句是在页面加载时就编译了
------解决方案--------------------JScript code
var iWidth = (window.screen.availWidth);
var iHeight = (window.screen.availHeight);
------解决方案--------------------