'WebPrograming/JSP'에 해당되는 글 3건
- 2013.01.18 <jsp:include> 팁
- 2012.06.11 뒤로가기 방지
- 2012.03.29 JSP 달력(CSS적용) 2
공통되는 부분을 <jsp:include>태그를 이용하여 간편하게 작성할 수 있지만 파일의 위치가 바뀌는 등의 수정을 할 경우가 생길 경우
이 태그를 사용한 모든 부분을 고쳐야한다.
이런 번거로움을 피할 수 있는 방법이 web.xml파일에서 <jsp:include>를 설정하는 방법이다.
다음과 같이 사용할 수 있다.
<jsp-config>
<jsp-property-group>
<url-pattern>/view/*</url-pattern>
<include-prelude>/menu/top.jsp</include-prelude>
<include-coda>/menu/bottom.jsp</include-coda>
</jsp-property-group>
</jsp-config>
<태그설명>
<url-pattern>/view/*</url-pattern> : 프로퍼티를 적용할 JSP파일에 해당되는 URL 패턴을 지정
<include-prelude /> : url-pattern에서 지정한 패턴에 해당되는 JSP파일의 앞에 자동으로 삽입될 페이지
<include-coda /> : url-pattern에서 지정한 패턴에 해당되는 JSP파일의 앞에 자동으로 삽입될 페이지
위와 같이 설정해두면 URL패턴이 view 의 경로에 있는 모든 페이지들은 로드될 때 <include-prelude />, <include-coda/>에 설정한 페이지들을 포함하여 보여진다.
'WebPrograming > JSP' 카테고리의 다른 글
| 뒤로가기 방지 (0) | 2012.06.11 |
|---|---|
| JSP 달력(CSS적용) (2) | 2012.03.29 |
response.setHeader("Cache-control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader("Expires",0);
<META http-equiv="Cache-Control" content="no-cache"/>
<META http-equiv="Expires" content="0"/>
<META http-equiv="Pragma" content="no-cache"/>
'WebPrograming > JSP' 카테고리의 다른 글
| <jsp:include> 팁 (0) | 2013.01.18 |
|---|---|
| JSP 달력(CSS적용) (2) | 2012.03.29 |
jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jsp를 이용한 달력</title>
<script type="text/javascript">
function selectCheck(form){
form.submit();
}
function monthDown(form){
if(form.month.value>1){
form.month.value--;
}else {
form.month.value=12;
form.year.value--;
}
form.submit();
}
function monthUp(form){
if(form.month.value<12){
form.month.value++;
}else {
form.month.value=1;
form.year.value++;
}
form.submit();
}
</script>
</head>
<body>
<%
//현재 날짜 정보
Calendar cr = Calendar.getInstance();
int year = cr.get(Calendar.YEAR);
int month = cr.get(Calendar.MONTH);
int date = cr.get(Calendar.DATE);
//오늘 날짜
String today = year + ":" +(month+1)+ ":"+date;
//선택한 연도 / 월
String input_year = request.getParameter("year");
String input_month = request.getParameter("month");
if(input_month != null){
month = Integer.parseInt(input_month)-1;
}
if(input_year != null){
year = Integer.parseInt(input_year);
}
// 1일부터 시작하는 달력을 만들기 위해 오늘의 연도,월을 셋팅하고 일부분은 1을 셋팅한다.
cr.set(year, month, 1);
// 셋팅한 날짜로 부터 아래 내용을 구함
// 해당 월의 첫날를 구함
int startDate = cr.getMinimum(Calendar.DATE);
// 해당 월의 마지막 날을 구함
int endDate = cr.getActualMaximum(Calendar.DATE);
// 1일의 요일을 구함
int startDay = cr.get(Calendar.DAY_OF_WEEK);
int count = 0;
%>
<form method="post" action="calendar.jsp" name="change">
<table width="400" cellpadding="2" cellspacing="0" border="0" align="center">
<tr>
<td width="140" align="right"><input type="button" value="◁" onClick="monthDown(this.form)"></td>
<td width="120" align="center">
<select name="year" onchange="selectCheck(this.form)">
<%
for(int i=year-10;i<year+10;i++){
String selected = (i == year)?"selected":"";
String color = (i == year)?"#CCCCCC":"#FFFFFF";
out.print("<option value="+i+" "+selected+" style=background:"+color+">"+i+"</option>");
}
%>
</select>
<select name="month" onchange="selectCheck(this.form)">
<%
for(int i=1;i<=12;i++){
String selected = (i == month+1)?"selected":"";
String color = (i == month+1)?"#CCCCCC":"#FFFFFF";
out.print("<option value="+i+" "+selected+" style=background:"+color+">"+i+"</option>");
}
%>
</select></td>
<td width="140"><input type="button" value="▷" onClick="monthUp(this.form)"></td>
</tr>
<tr>
<td align="right" colspan="3"><a href="calendar.jsp"><font size="2">오늘 : <%=today %></font></a></td>
</tr>
</table>
</form>
<table width="400" cellpadding="2" cellspacing="0" border="1" align="center">
<tr height="30">
<td><font size="2">일</font></td>
<td><font size="2">월</font></td>
<td><font size="2">화</font></td>
<td><font size="2">수</font></td>
<td><font size="2">목</font></td>
<td><font size="2">금</font></td>
<td><font size="2">토</font></td>
</tr>
<tr height="30">
<%
for (int i=1;i<startDay;i++){
count++;
%>
<td> </td>
<%
}
for (int i=startDate;i<=endDate;i++){
String bgcolor = (today.equals(year+":"+(month+1)+":"+i))? "#CCCCCC" : "#FFFFFF";
String color = (count%7 == 0 || count%7 == 6)? "red" : "black";
count++;
%>
<td bgcolor="<%=bgcolor %>"><font size="2" color=<%=color %>><%=i %></font></td>
<%
if(count%7 == 0 && i < endDate){
%>
</tr>
<tr height="30">
<%
}
}
while(count%7 != 0){
%>
<td> </td>
<%
count++;
}
%>
</tr>
</table>
</body>
</html>
css
@charset "utf-8";
* {
margin: 0;
padding: 0;
line-height: 1.5;
font-family: gulim, sans-serif;
font-size:110%;
text-align:center;
}
.a2{
font-size:20px;
text-decoration: none;
color: #5c5c5c;
}
.list_over { background-color:#F3F7FD; }
.list_out { background-color:#FFFFFF; }
.list_over2 { background-color:#e5e5e5; }
a {
text-decoration: none;
color: #5c5c5c;
}
#today{
background-color:#CCCCCC;
color:#000000;
}
.base{
border:1px solid #8e8e8e;
}
.sun{
border:1px solid #8e8e8e;
color:#FF0000;
}
tr{
height:11%;
}
a:hover {
text-decoration: underline;
color: #5c5c5c;
}
.dot {style;
border-top-style: dashed;
border-right-style: dashed;
border-bottom-style: dashed;
border-left-style: dashed;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-color: rgb(71, 71, 71);
border-right-color: rgb(71, 71, 71);
border-bottom-color: rgb(71, 71, 71);
border-left-color: rgb(71, 71, 71);
background-color: rgb(232, 232, 232);
padding-top: 10px;
padding-right: 10px;
padding-bottom: 10px;
padding-left: 10px;
p style:margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
table {
border-collapse: collapse;
border-cellpadding: cellpadding;
height:100%;width:100%;
align:center;border:0;
}
주석안에 설명 다 있습니다.
CSS
마우스 온오버 효과 ,오늘날짜 표시,일요일 빨간색
'WebPrograming > JSP' 카테고리의 다른 글
| <jsp:include> 팁 (0) | 2013.01.18 |
|---|---|
| 뒤로가기 방지 (0) | 2012.06.11 |