当前位置: 技术问答>java相关
请教Servlet问题
来源: 互联网 发布时间:2015-09-19
本文导语: 我按书上的例子遍了一个servlet的程序,用jBuilder编译总是有问题 import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; public class Servlet1 extends HttpServlet { ResourceBundle rb=ResourceBundle.getBundle("LocalStr...
我按书上的例子遍了一个servlet的程序,用jBuilder编译总是有问题
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Servlet1 extends HttpServlet {
ResourceBundle rb=ResourceBundle.getBundle("LocalStrings");
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=GBK");
PrintWriter out = response.getWriter();
out.println("");
out.println("Servlet1");
out.println("");
out.println("
Enumeration e=request.getParameterNames();
while(e.hasMoreElements())
{
String name=(String)e.nextElement();
String value=request.getParameter(name);
out.println(name+"==="+value);
}
out.println("");
}
/**Clean up resources*/
public void destroy() {
}
}
报错的信息是:
Warning #: 908 : check sourcepath; source d:WINDOWSjbprojectservletServlet1.java cannot be found on sourcepath by appending Servlet1.java to each sourcepath entry
每次编译就弹出一个runtime properties的对话框,好象要填什么,按OK以后又有一个
Message说Unable to start runtime due to incomplete configuration
是否配置有问题??
另外,我想请问如果直接用JDK+resin怎样使用servlet,应该把class文件放在哪个目录?
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Servlet1 extends HttpServlet {
ResourceBundle rb=ResourceBundle.getBundle("LocalStrings");
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=GBK");
PrintWriter out = response.getWriter();
out.println("");
out.println("Servlet1");
out.println("");
out.println("
The servlet has received a POST. This is the reply.
");Enumeration e=request.getParameterNames();
while(e.hasMoreElements())
{
String name=(String)e.nextElement();
String value=request.getParameter(name);
out.println(name+"==="+value);
}
out.println("");
}
/**Clean up resources*/
public void destroy() {
}
}
报错的信息是:
Warning #: 908 : check sourcepath; source d:WINDOWSjbprojectservletServlet1.java cannot be found on sourcepath by appending Servlet1.java to each sourcepath entry
每次编译就弹出一个runtime properties的对话框,好象要填什么,按OK以后又有一个
Message说Unable to start runtime due to incomplete configuration
是否配置有问题??
另外,我想请问如果直接用JDK+resin怎样使用servlet,应该把class文件放在哪个目录?
|
程序不会有什么错,servlet运行要 应用服务器环境,Jbuilder自带Tomcat
在jbuilder中 new 一个jsp ,会自动加入1个web运行环境,你就可以调用你的servlet了,建议你看一下jbuilder/samples目录下的东东,或者自己按照向导new 点jsp servlet beans,看看他们的关系,good luck!
在jbuilder中 new 一个jsp ,会自动加入1个web运行环境,你就可以调用你的servlet了,建议你看一下jbuilder/samples目录下的东东,或者自己按照向导new 点jsp servlet beans,看看他们的关系,good luck!