当前位置: 技术问答>java相关
用Java Servlet作一个表单的提交程序
来源: 互联网 发布时间:2015-01-20
本文导语: 我用Java Servlet作一个表单的提交程序,要将表单中的值提取后显示出来,在运行时出现如下错误 Error: 500 Location: /examples/servlet/ParmExtractorServlet Internal Servlet Error: java.lang.NullPointerException at java.lang.ClassLoader.r...
我用Java Servlet作一个表单的提交程序,要将表单中的值提取后显示出来,在运行时出现如下错误
Error: 500
Location: /examples/servlet/ParmExtractorServlet
Internal Servlet Error:
java.lang.NullPointerException
at java.lang.ClassLoader.resolveClass0(Native Method)
at java.lang.ClassLoader.resolveClass(ClassLoader.java:588)
at org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.java:430)
at org.apache.tomcat.loader.AdaptiveServletLoader.loadClass(AdaptiveServletLoader.java:174)
at org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:265)
at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289)
at org.apache.tomcat.core.Handler.service(Handler.java:254)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
源程序如下:
package ijs.forms;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ParmExtractorServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
response.setContentType("text/plain");
ServletOutputStream out=response.getOutputStream();
Enumeration eParmNames=request.getParameterNames();
while(eParmNames.hasMoreElements())
{
String name=(String)eParmNames.nextElement();
String value=request.getParameter(name);
out.println(name+"="+value);
}
}
}
Error: 500
Location: /examples/servlet/ParmExtractorServlet
Internal Servlet Error:
java.lang.NullPointerException
at java.lang.ClassLoader.resolveClass0(Native Method)
at java.lang.ClassLoader.resolveClass(ClassLoader.java:588)
at org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.java:430)
at org.apache.tomcat.loader.AdaptiveServletLoader.loadClass(AdaptiveServletLoader.java:174)
at org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:265)
at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289)
at org.apache.tomcat.core.Handler.service(Handler.java:254)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
源程序如下:
package ijs.forms;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ParmExtractorServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
response.setContentType("text/plain");
ServletOutputStream out=response.getOutputStream();
Enumeration eParmNames=request.getParameterNames();
while(eParmNames.hasMoreElements())
{
String name=(String)eParmNames.nextElement();
String value=request.getParameter(name);
out.println(name+"="+value);
}
}
}
|
url要变成: http://hostname:port/examples/servlet/ijs.forms.ParmExtractorServlet
|
examples/servlet/ijs.forms.ParmExtractorServlet?...