主题:运行.java文件,为什么把源码给显示出来了呀?
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet{
public void doGet(HttpServletResponse response) throws IOException,ServletException{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<body bgcolor=\"white\">");
out.println("<head>");
out.println("<title>"+"JSP简单程序实例二"+"</title>");
out.println("</head>");
out.println("<body>");
out.println("<div align='center'>");
out.println("<p> </p>");
out.println("<p> </p>");
out.println("<p><font size='+4'>"+"Hello World!"+"</font></p>");
out.println("</div>");
out.println("</body>");
out.println("</html>");
}
}
==================================
以上是HelloWorld.java文件的内容,编译之后,运行:
http://localhost:8080/jsp/HelloWorld.java,结果把源码给显示出来了,请问怎么解决?
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet{
public void doGet(HttpServletResponse response) throws IOException,ServletException{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<body bgcolor=\"white\">");
out.println("<head>");
out.println("<title>"+"JSP简单程序实例二"+"</title>");
out.println("</head>");
out.println("<body>");
out.println("<div align='center'>");
out.println("<p> </p>");
out.println("<p> </p>");
out.println("<p><font size='+4'>"+"Hello World!"+"</font></p>");
out.println("</div>");
out.println("</body>");
out.println("</html>");
}
}
==================================
以上是HelloWorld.java文件的内容,编译之后,运行:
http://localhost:8080/jsp/HelloWorld.java,结果把源码给显示出来了,请问怎么解决?