Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Servlet/JSP/JSF/JavaFX Script  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to postflat modethreaded modego to previous topicgo to next topicgo to back
作者 [求助]Servlet奇怪问题
robinlet





发贴: 6
于 2005-04-23 20:40 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
写了一个简单的Servlet

package edu.hit.ims.study.servlet;

import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/

public class MyServlet
extends HttpServlet {

public void init(ServletConfig config) throws ServletException {
super.init(config);
}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType("test/html;charset=GB2312");

PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>Hello Servlet!</head>");
out.println("<body>");
out.println("Hello World!");
out.println("大家好!");
out.println("</body>");
out.println("</html>");
out.close();
}

public String getServletInfo() {
return "edu.hit.ims.study.servlet.MyServlet Information!";
}

public void destroy() {

}

}

一个HelloJsp.jsp
<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
hellojsp
</title>
</head>
<body bgcolor="#ffffff">
<h1>
Hello!jsp
</h1>
<form method="post">
<br><br>
<input type="submit" name="Submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>

web.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>edu.hit.ims.study.servlet.MyServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>debugjsp</servlet-name>
<description>Added to compile JSPs with debug info</description>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>classdebuginfo</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>HelloJsp.jsp</welcome-file>
</welcome-file-list>
</web-app>

使用 jb9, ie6

在浏览器中输入
http://localhost:8083/webapp/MyServlet
提示让我选择保存/打开MyServlet 文件。
输入 http://localhost:8083/webapp/HelloJsp.jsp
http://localhost:8083/webapp/
提示让我选择保存/打开 HelloJsp.jsp文件。

但是我选择用IE打开的时候又能正常显示。
这是怎么回事?????很奇怪。




关于 异常 。。。。 谢谢指教

话题树型展开
人气 标题 作者 字数 发贴时间
1860 [求助]Servlet奇怪问题 robinlet 2705 2005-04-23 20:40
1307 Re:[求助]Servlet奇怪问题 bluepure 145 2005-04-23 21:37
1456 Re:[求助]Servlet奇怪问题 robinlet 65 2005-04-23 21:47

reply to postflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923