首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

请教小弟我页面不能响应试咋回事

2012-02-21 
请问我页面不能响应试怎么回事我写的新闻页面,在打开时共要读取两次数据,分别用于生成菜单和新闻列表,但我

请问我页面不能响应试怎么回事
我写的新闻页面,在打开时共要读取两次数据,分别用于生成菜单和新闻列表,但我发现当我页面大开后,响应十分慢,甚至无法响应,也就是在我启动服务的一开始的几分钟内,响应及时,过了几分钟后就变慢了,甚至无法响应,我检查并没报错,我用来测试的数据十分少只有16条。
请问是怎么回事。
以下是我的代码:
-------------------------jsp-----------------------------------
<%@ page language="java" pageEncoding="utf-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
  <head>
  <html:base />
   
  <title>news</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">
<link rel="stylesheet" type="text/css" href="css/body.css">
<script type="text/javascript" src="http://w3css.com/down/js/pngfix.js"></script>
<script type="text/javascript">
function add(){
document.getElementById("id").value = <%=request.getParameter("id") %>
var comment = document.getElementById("comment");
if(comment.value == null ||comment.value ==""){
alert("不能发表空评论!");
return false;
}

}
</script>
  </head>
  
  <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
  <table cellpadding="0" cellspacing="0" border="0">
  <tr>
  <td>
  <table cellpadding="0" cellspacing="0" border="0">
  <tr>
  <td>
  <jsp:include page="head2.jsp" flush="true"></jsp:include>
  </td>
  </tr>
  </table>
  </td>
  </tr>
 
  <tr>
  <td>
<table cellpadding="0" cellspacing="0" border="0">
  <tr>
  <td>&nbsp;&nbsp;</td>
  <td>
  <img border="0" src="news/direction.png" width="248" height="30">
  </td>
  </tr>
  </table>
  </td>
  </tr>
 
  <tr><td>&nbsp;</td></tr>
 
  <tr>
  <td>
  <table cellpadding="0" cellspacing="0" border="0">
  <tr>
  <td>&nbsp;&nbsp;</td>
 
  <td valign="top">
  <table border="0" cellpadding="0" cellspacing="0">
  <tr>
  <td style="background-image:url('news/logo.gif');width:217px;height:47px"></td>


  </tr>
  <tr>
  <td align="center" valign="top" style="background-image:url('news/menubg.gif');width:217px;height:308px">
  <table cellpadding="0" cellspacing="0" border="0" >
  <tr><td>&nbsp;</td></tr>
  <logic:present name="menu">
  <logic:notEmpty name="menu">
  <logic:iterate id="menu" name="menu" type="com.website.struts.entity.NewType">
  <tr>
  <td align="center">
  <table border="0" cellpadding="0" cellspacing="0">
  <tr>
  <td align="center" style="background-image:url('news/itembg.gif');width:217;height:32;font-size:20px;font-family:宋体-方正超大字符集;color:#ffffff">
  <a href="<%=request.getContextPath()%>/newinfo.do?type=<bean:write property="typeid" name="menu"/>">
  <bean:write property="typename" name="menu"/></a>
  </td>
  </tr>
 
  </table>
 
  </td>
  </tr>
  <tr><td>&nbsp;</td></tr>
  </logic:iterate>
  </logic:notEmpty>
  </logic:present>
  </table>
</td>
  </tr>
  <tr>
  <td style="background-image:url('news/menubot.gif');width:217px;height:170px"></td>
  </tr>
  </table>
  </td>
 
  <td>&nbsp;&nbsp;</td>
 
  <td valign="top">
  <table cellpadding="0" cellspacing="0" border="0">
  <tr>
  <td style="background-image:url('news/contop.gif');width:723px;height:7px"></td>
  </tr>
  <tr>
  <td align="left" style="font-size:14px;font-family:宋体;color:#666666;background-image:url('news/conicon.gif');width:217px;height:29px">
  &nbsp;系统公告
  </td>
  </tr>
  <tr>
  <td valign="top" align="center" style="background-image:url('news/conbg.gif');width:723px;height:500px">
  <logic:present name="news">
  <logic:notEmpty name="news">
  <logic:iterate id="news" name="news" type="com.website.struts.entity.NewContents">
  <table border="0" cellpadding="0" cellspacing="0">
  <tr>
  <td align="center" style="font-size:12px;font-family:宋体;color:#999999;word-break:break-all" width="700">
  <bean:write property="title" name="news" />
  <!--标题 -->


  </td>
  </tr>
 
<tr><td>&nbsp;</td></tr>
 
  <tr>
  <td align="left" style="font-size:12px;font-family:宋体;color:#999999;word-break:break-all" width="700">
  &nbsp;&nbsp;<bean:write property="content" name="news"/>
  <!--内容 -->
  </td>
  </tr>
 
  <tr><td>&nbsp;</td></tr>
 
<tr>
  <td><!-- comment -->
  <html:form action="comment.do" method="post" onsubmit="return add();">
  <table border="0" cellpadding="0" cellspacing="0">
  <tr>
  <td>
  对此条新闻发表评论
  </td>
  </tr>
  <tr>
  <td><html:hidden property="id"/>
  </td>
  </tr>
  <tr>
  <td width="100%">
  <html:textarea property="comment" rows="5" cols="70">
  </html:textarea>
  </td>
  </tr>
  <tr>
  <td align="right">
  <html:submit value="发表" ></html:submit>
  </td>
  </tr>
  </table>
  </html:form>
  <table></table>
  </td>
  </tr>
 
  </table>
  </logic:iterate>
  </logic:notEmpty>
  </logic:present>
 
  </td>
  </tr>
  <tr>
  <td style="background-image:url('news/conbot.gif');width:723px;height:5px"></td>
  </tr>
 
  </table>
  </td>
 
  </tr>
  </table>
  </td>
  </tr>
  </table>
  </body>
</html:html>


[解决办法]

探讨
还有就是我获取客户的IP,我获取的是动态的IP,并将获取的方法放在存储数据的数据操作的方法中。但我发现我获取的都是我的IP而不是客户的IP,请问是怎么回事?我的代码如下:
------------------获取的动态的ip------------------------------
public String GetDynaIP() throws UnknownHostException {
return String.valueOf(InetAddress.getByName(InetAddress.getLocalHost().getCanonicalHostName()).getHostAddress(…

热点排行