공유 Servlet

jinkyung·2021년 1월 19일
0

JSP

목록 보기
4/20

모든 서블릿에서 공유가 가능하도록 xml파일 수정

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
  <display-name>_12_JDBCServlet_ServletInitParam</display-name>
  
  
  <!-- 컨텍스트 초기화 매개변수(모든 서블릿에서 공유가능) -->

  	<context-param>
  		<param-name>driver</param-name>
  		<param-value>com.mysql.cj.jdbc.Driver</param-value>
  	</context-param>
  	<context-param>
  		<param-name>url</param-name>
  		<param-value>jdbc:mysql://localhost/studydb?serverTimezone=UTC</param-value>
  	</context-param>
  	<context-param>
  		<param-name>username</param-name>
  		<param-value>study</param-value>
  	</context-param>
  	<context-param>
  		<param-name>password</param-name>
  		<param-value>study</param-value>
  	</context-param>

  
  
  
  
  <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>

context를 받도록 java 코드를 수정하였다.

0개의 댓글