비전공개미 개발노트
[JSP] web.xml파일을 이용해 초기 id, pw 설정 및 확인 본문
반응형
SMALL
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_4_0.xsd" version="4.0">
<display-name>bit_jsp</display-name>
<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>
<!-- context-param추가 / xml파일은 반영되려면 서버를 restart되야 함 -->
<context-param>
<param-name>adminId</param-name>
<param-value>admin</param-value>
</context-param>
<context-param>
<param-name>adminPwd</param-name>
<param-value>1234</param-value>
</context-param>
</web-app>
ex12.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
관리자 아이디 : <%=application.getInitParameter("adminId") %><br>
관리자 비밀번호 : <%=application.getInitParameter("adminPwd") %>
</body>
</html>
[출력]
관리자 아이디 : admin
관리자 비밀번호 : 1234
반응형
LIST
'프로그래밍 > JSP' 카테고리의 다른 글
[JSP] jsp:include를 사용해 페이지 불러오기 (1) | 2022.10.11 |
---|---|
[JSP] jsp:forward를 사용해 페이지 불러오기 (1) | 2022.10.11 |
[JSP] include로 header / footer 붙이기 (0) | 2022.10.11 |
[JSP] 값이 틀릴시 errorPage로 이동 (0) | 2022.10.11 |
[JSP] 기초, HTML에서 사용방법 (1) | 2022.10.11 |
Comments