예를 들어 here과 here과 같은 비슷한 질문이 있지만 두 경우 모두 결과가 콘솔에 인쇄되는 반면 내 경우에는 아무것도.HTTP 메서드 GET은이 URL에서 지원되지 않습니다. 콘솔에 아무것도 인쇄하지 않습니다.
문제는 브라우저 화면에 뭔가를 인쇄하고 싶은 Java Servlet 하위 클래스가 있다는 것입니다.
이 내 서블릿의 서브 클래스입니다 : 내가 서블릿에 매핑되는 URL을 갈 때, 그것은 화면이 출력
package instrurental_proj.servlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Bla extends HttpServlet {
private static final long serialVersionUID = 16252534;
private static int ping = 3000;
private Thread t;
private static boolean shouldStop = false;
@Override
public void init() throws ServletException {
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("doGet");
PrintWriter out = resp.getWriter();
out.println("<html><h1>It works!!</h1></html>");
}
@Override
public void service(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
System.out.println("service");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("doPost");
}
@Override
public void destroy() {
System.out.println("Destroy servlet");
shouldStop = true;
}
}
이 내 web.xml
입니다 :
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Bla</servlet-name>
<servlet-class>instrurental_proj.servlets.Bla</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Bla</servlet-name>
<url-pattern>/bla</url-pattern>
</servlet-mapping>
</web-app>
서버를 실행할 때 콘솔이 출력합니다.
Aug 31, 2014 12:50:36 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\ActiveState Komodo Edit 8\;C:\Program Files (x86)\Haskell\bin;C:\Program Files (x86)\Haskell Platform\2013.2.0.0\lib\extralibs\bin;C:\Program Files (x86)\Haskell Platform\2013.2.0.0\bin;C:\Program Files (x86)\HP SimplePass\x64;C:\Program Files (x86)\HP SimplePass\;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Java\jdk1.7.0_25\bin;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files (x86)\Autodesk\Backburner\;C:\Program Files (x86)\PostgreSQL\9.3\lib;C:\Program Files\SourceGear\Common\DiffMerge\;C:\Program Files (x86)\QuickTime\QTSystem;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Haskell Platform\2013.2.0.0\mingw\bin;C:\Anaconda;C:\Anaconda\Scripts;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\VisualSVN Server\bin;C:\wamp\bin\php\php5.4.12;C:\ProgramData\ComposerSetup\bin;C:\Program Files (x86)\Boundless\OpenGeo\bin;C:\Program Files (x86)\Boundless\OpenGeo\jetty\jre\bin;C:\Program Files\Java\jdk1.7.0_25;C:\Users\Imray\AppData\Roaming\cabal\bin;C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;C:\Program Files (x86)\Nmap;C:\Program Files (x86)\Google\google_appengine\;C:\Program Files (x86)\Apache Software Foundation\apache-maven-3.2.3\bin;.
Aug 31, 2014 12:50:36 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:instrurental_proj' did not find a matching property.
Aug 31, 2014 12:50:36 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Aug 31, 2014 12:50:36 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Aug 31, 2014 12:50:36 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 465 ms
Aug 31, 2014 12:50:36 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Aug 31, 2014 12:50:36 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Aug 31, 2014 12:50:36 PM org.apache.catalina.realm.JDBCRealm startInternal
SEVERE: Exception opening database connection
java.sql.SQLException: org.postgresql.Driver
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:692)
at org.apache.catalina.realm.JDBCRealm.startInternal(JDBCRealm.java:780)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5350)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:688)
... 11 more
Aug 31, 2014 12:50:38 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Aug 31, 2014 12:50:38 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Aug 31, 2014 12:50:38 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1617 ms
올바른 설정과 서블릿을 표시 하시겠습니까? 405. –
@SotiriosDelimanolis 예 100 % 확신 – CodyBugstein
음 ... 나는 그것을 볼 수 없습니다. 컨테이너 로그를 열고 인쇄 한 내용을 보여주십시오. –