servlet 急!!!

wo_huai 2007-01-09 10:45:53
servlet..
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
String id="1";

request.setAttribute(id,"id");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>NewsServlet</title></head>");
out.println("<body bgcolor=\"#ffffff\">");
out.println("<input type='hidden' name='id' value='"+id+"'>");
out.println("<script>window.navigate('maupdatehealthNews.jsp')</script>");
out.println("</body>");
out.println("</html>");
out.close();
}
maupdatehealthNews.jsp

<html>
<body>
<%
String id=(String)request.getAttribute("id");
out.print(id);
%>
</body>
</html>

为什么得不到servlet的id 值啊
...全文
200 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wo_huai 2007-01-09
  • 打赏
  • 举报
回复
哦 我 在看下
lcllcl987 2007-01-09
  • 打赏
  • 举报
回复
你给的分应等于20,如果大于20,就不行
wo_huai 2007-01-09
  • 打赏
  • 举报
回复
给分怎么老是说贴子回复次数大于跟给分次数 阿?
很想给朋友们分阿
lcllcl987 2007-01-09
  • 打赏
  • 举报
回复
out.println("<script>window.navigate('maupdatehealthNews.jsp')</script>");

这句不对,应类似下面的语句跳转:
RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/csvmgmt/csvup.jsp?selected=" + result.substring(0, result.indexOf("!")) + "&pageId=1&result=" + result.substring(result.indexOf("!") + 1));
rd.forward(request, response);
lvf20 2007-01-09
  • 打赏
  • 举报
回复
servlet..
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
String id="1";

request.setAttribute(id,"id");


RequestDispatcher view=request.getRequestDispatch("'maupdatehealthNews.jsp");
view.forward(request,response);//把请求响应对象带入到jsp中

这样就行了,不要用servlet写html。
lvf20 2007-01-09
  • 打赏
  • 举报
回复
servlet..
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
String id="1";

request.setAttribute(id,"id");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>NewsServlet</title></head>");
out.println("<body bgcolor=\"#ffffff\">");
out.println("<input type='hidden' name='id' value='"+id+"'>");
out.println("<script>window.navigate('maupdatehealthNews.jsp')</script>"); //这么跳转好像不行
out.println("</body>");
out.println("</html>");
out.close();
}

RequestDispatcher view=request.getRequestDispatch("'maupdatehealthNews.jsp");
view.forward(request,response);//把请求响应对象带入到jsp中
wo_huai 2007-01-09
  • 打赏
  • 举报
回复
还是得不到阿?
能不能在给我看看
谢谢先
kyoses 2007-01-09
  • 打赏
  • 举报
回复
servlet..
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
String id="1";

request.setAttribute(id,"id");//这句错了吧 应该是request.setAttribute("id",id);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>NewsServlet</title></head>");
out.println("<body bgcolor=\"#ffffff\">");
out.println("<input type='hidden' name='id' value='"+id+"'>");
out.println("<script>window.navigate('maupdatehealthNews.jsp')</script>");

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧