2014-02-10 2 views
-1

웹 응용 프로그램 프로젝트 인 다른 프로젝트에있는 서블릿에 문자열을 보내는 JSP 파일이있는 동적 응용 프로그램이 있습니다. 나는 JSP 프로젝트에서 Tomcat 서버를 사용하고 있으며 서버는 정상적으로 시작하고 있지만 로컬 호스트에서 웹 응용 프로그램을 실행할 때 HTTP 오류 500이 발생했습니다. /jsptoservlettocloud에 액세스하는 데 문제가 있습니다. 이유 : 내부 서버 오류웹 응용 프로그램 프로젝트의 내부 서버 오류

이 문제는이 내 web.xml 파일

<servlet> 
    <servlet-name>JSPToServletToCloud</servlet-name> 
    <servlet-class>pack.exp.JSPToServletToCloudServlet</servlet-class> 
</servlet> 
<servlet-mapping> 
    <servlet-name>JSPToServletToCloud</servlet-name> 
    <url-pattern>/jsptoservlettocloud</url-pattern> 
</servlet-mapping> 
<welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
</welcome-file-list> 
</web-app> 

이 ServletToCloud가되는 URL에

public class JSPToServletToCloudServlet extends HttpServlet 
{ 
String str; 
protected void doGet(HttpServletRequest request, HttpServletResponse response) 
    throws ServletException, IOException 
    { 
     ObjectInputStream ois = new ObjectInputStream(request.getInputStream()); 

     try 
      { 
       str= (String) ois.readObject(); 
     } 

     catch (ClassNotFoundException e) 
     { 
      e.printStackTrace(); 
     } 

     finally 
     { 
     ois.close(); 
     } 
    System.out.println("Servlet received : " + str); 
} 
} 

내 서블릿 클래스 내 JSP 파일

<body> 
<% 
    String str= "Shanx"; 

    URL u = new 
     URL("http://localhost:8080/ServletToCloud/JSPToServletToCloudServlet"); 

     HttpURLConnection huc = (HttpURLConnection)u.openConnection(); 
     huc.setRequestMethod("GET"); 
     huc.setDoOutput(true); 

     ObjectOutputStream objOut = new ObjectOutputStream(huc.getOutputStream()); 
     objOut.writeObject(str); 
     objOut.flush(); 
     objOut.close(); 
%> 
</body> 

입니다 웹 애플리케이션 프로젝트의 이름과 JSPToServletToCloudServlet은 서블릿의 이름입니다. 이 URL이 맞습니까?

+0

web.xml의 모양은 무엇입니까? – rocketboy

+0

u r "huc.setRequestMethod ("POST ");" 요청 및 ur 서블릿 doGet() doGet()하지 doPost()하지 않습니다. – Arvind

+0

@ rocketboy 나는 질문에 그것을 추가했습니다. – user3273473

답변

0

귀하의 JSP에 http://localhost:8080/ServletToCloud/JSPToServletToCloudServlet이 있지만 귀하의 web.xml에 /jsptoservlettocloud이 있습니다. 매핑이 잘못되었습니다.

관련 문제