Java 如何在 NetBeans IDE 中运行 servlet 程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2673371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run the servlet program in NetBeans IDE?
提问by Venkat
I am new to java servlets. I learning from the basic. I have a simple servlet program, but I don't know how to run it.
我是 Java servlet 的新手。我从基础开始学习。我有一个简单的 servlet 程序,但我不知道如何运行它。
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter out = response.getWriter();
out.println("Hello World");
}
}
How can run the above program in NetBeans. I am using the netbeans6.8. What are the procedures which I have to follow?
如何在 NetBeans 中运行上述程序。我正在使用netbeans6.8。我必须遵循哪些程序?
采纳答案by Jon
You need to make sure you've created a web application project in Netbeans, then you should be able to run your Servlet as part of it. This guide is for Netbeans 5 but the principles should be still the same:
您需要确保您已经在 Netbeans 中创建了一个 Web 应用程序项目,然后您应该能够将您的 Servlet 作为它的一部分运行。本指南适用于 Netbeans 5,但原则应该保持不变:
https://www.java-tips.org/java-tutorials/1506-introduction-to-java-servlets-with-netbeans.html]1
https://www.java-tips.org/java-tutorials/1506-introduction-to-java-servlets-with-netbeans.html] 1
回答by Jon
The Java EE and Java Web Learning trailshould help you get started.
在的Java EE和Java Web学习资源应该可以帮助您开始。