1

i want to integrate the H2 console into my web application,and i try this code: in web.xml file:

    <?xml version="1.0" encoding="UTF-8"?>  
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">  
  <display-name>h2Wrapper</display-name>  
  <servlet>  
    <servlet-name>H2Console</servlet-name>  
    <servlet-class>org.h2.server.web.WebServlet</servlet-class>  

    <init-param>  
      <param-name>webAllowOthers</param-name>  
      <param-value>true</param-value>  
    </init-param>  
    <load-on-startup>1</load-on-startup>  
  </servlet>  
  <servlet-mapping>  
    <servlet-name>H2Console</servlet-name>  
    <url-pattern>/h2/*</url-pattern>  
  </servlet-mapping>  
  <welcome-file-list>  
    <welcome-file>index.html</welcome-file>  
    <welcome-file>index.htm</welcome-file>  
    <welcome-file>index.jsp</welcome-file>  
    <welcome-file>default.html</welcome-file>  
    <welcome-file>default.htm</welcome-file>  
    <welcome-file>default.jsp</welcome-file>  
  </welcome-file-list>  
</web-app>  

and in the index.jsp file:

 <body>
  <form method="POST" action="/h2/console/login.jsp">
<input type="hidden" name="user" value="sa" />
<input type="hidden" name="password" value="" />
<input type="hidden" name="driver" value="org.h2.Driver" />
<input type="hidden" name="language" value="en" />
<input type="hidden" name="setting" value="Generic H2 (Embedded)" />
<input type="hidden" name="name" value="Generic H2 (Embedded)" />
<input type="hidden" name="url" value="jdbc:h2:C:\path\to\my\h2\db" />
<input type="submit" value="H2"/>
</form>
  </body>

but it give me this error: The requested resource (/h2/console/login.jsp) is not available.

can you help me please? and what should be do? thank you...

mimo
  • 97
  • 1
  • 2
  • 6
  • Did you try "/h2/login.jsp" ? – Thomas Mueller Sep 03 '13 at 14:30
  • yes but it doesn't work,the same error appears – mimo Sep 04 '13 at 06:14
  • If you try connecting to "/h2/login.jsp" using a browser, is there anything in the log file? – Thomas Mueller Sep 04 '13 at 06:37
  • my web application is running in jboss 7 (127.0.0.1:8080/mywebApp) and the port number of h2 is 8083(127.0.0.1:8083/login.jsp) is it possible that the port number cause this probleme? – mimo Sep 04 '13 at 06:50
  • If you use the H2Console servlet within your web application (127.0.0.1:8080/mywebApp), then you don't need to use the H2 standalone server (127.0.0.1:8083/login.jsp). Again, if you try connecting to "http://127.0.0.1:8080/h2/login.jsp" using a browser (after starting your web application), is there anything in the log file? – Thomas Mueller Sep 04 '13 at 08:09
  • no,but it display a error page in browser:The requested resource (/h2/login.jsp) is not available. – mimo Sep 04 '13 at 08:28
  • i don't know how to resolve this problem please help me – mimo Sep 04 '13 at 08:46
  • see this [answer](https://stackoverflow.com/questions/35061633/how-to-connect-h2-console-to-embedded-spring-h2-db) for nont spring-bbot application with web.xml – Ahmad R. Nazemi Jun 19 '17 at 09:28

0 Answers0