<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

include 와 상관 없이 jsp 모든 파일의 첫부분에 위 문장이 있어야 UTF-8 이 적용된다.


파일 경로 및 파일명 확인

<%

String ThisFilePath = request.getServletPath ( ) ; ThisFilePath = ThisFilePath.substring ( 0 , ThisFilePath.lastIndexOf ( "/" ) + 1 ) ;

String ThisFile = request.getServletPath ( ) ; ThisFile = ThisFile.substring ( ThisFile.lastIndexOf ( "/" ) + 1 ) ;

out.print ( "<div style=\"text-align:left;\">" ) ;

out.print ( "<B style=\"color:#FF0000\">" + request.getScheme ( ) + "://" + request.getServerName ( ) + ":" + request.getServerPort ( ) + request.getContextPath ( ) + "</B><BR>" ) ;

out.print ( "<B>ThisFilePath </B> " + ThisFilePath + "<BR>" ) ;

out.print ( "<B>ThisFile </B> " + ThisFile + "<BR>" ) ;

out.print ( "<B>request.getServletPath() </B> " + request.getServletPath() + "<BR>" ) ;

out.print ( "<B>request.getRequestURI ( ) </B> " + request.getRequestURI ( ) + "<BR>" ) ;

out.print ( "<B>request.getRequestURL ( ) </B> " + request.getRequestURL ( ) + "<BR>" ) ;

out.print ( "<B>request.getContextPath ( ) </B> " + request.getContextPath ( ) + "<BR>" ) ;

out.print ( "<B>request.getQueryString ( ) </B> " + request.getQueryString ( ) + "<BR>" ) ;

out.print ( "<B>request.getHeader(\"REFERER\") </B> " + request.getHeader("REFERER") + "<BR>" ) ;

out.print ( "<B>request.getScheme ( ) </B> " + request.getScheme ( ) + "<BR>" ) ;

out.print ( "<B>request.getServerName ( ) </B> " + request.getServerName ( ) + "<BR>" ) ;

out.print ( "<B>request.getServerPort ( ) </B> " + request.getServerPort ( ) + "<BR>" ) ;

out.print ( "<B>application.getRealPath(request.getServletPath()) </B> " + application.getRealPath(request.getServletPath()) + "<BR>" ) ;

out.print ( "<B>application.getRealPath(request.getContextPath()) </B> " + application.getRealPath(request.getContextPath()) + "<BR>" ) ;

out.print ( "</div>" ) ;

%>


날자 시간 확인.

<%

try {


DateFormat df = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss.SSS" ) ;

long CurDateTime = System.currentTimeMillis ( ) ;

Date CurDate = new Date ( CurDateTime ) ;

out.println ( "CurrentTimeMillis: " + CurDateTime + "<BR>" ) ;

out.println ( "Current Date: " + CurDate + "<BR>" ) ;

out.println ( "Milliseconds to Date: " + df.format ( CurDateTime ) + "<BR>" ) ;


Calendar cal = Calendar.getInstance ( ) ;

cal.setTimeInMillis ( CurDateTime ) ;


out.println ( "Milliseconds to Date using Calendar:" + df.format ( cal.getTime ( ) ) + "<BR>" ) ;


Date now = new Date ( ) ;

Date copiedDate = new Date ( now.getTime ( ) ) ;

out.println ( "original Date: " + df.format ( now ) + "<BR>" ) ;

out.println ( "copied Date: " + df.format ( copiedDate ) + "<BR>" ) ;


} catch ( Exception e ) { out.print ( e ) ; } finally { }

%>


모든 파라미터 확인

<%
Enumeration eNames = request.getParameterNames ( ) ;

if ( eNames.hasMoreElements ( ) )
{
 int count = 0 ;
 Map entries = new TreeMap ( ) ;

 out.print ( "<table style=\"background-color:transparent; border-spacing:0px; border-collapse:collapse; border:0px; margin:0px; padding:0px;\">" ) ;
 
 while ( eNames.hasMoreElements ( ) )
 {
  String name = (String) eNames.nextElement ( ) ;
  String [ ] values = request.getParameterValues ( name ) ;

  if ( values.length > 0 )
  {
   String value = values [ 0 ] ;

   for ( int i = 1 ; i < values.length ; i ++ )
   {
    value += "," + values [ i ] ;
   }

   out.println ( "<tr><td style=\"padding:4px;  border:1px #000000 solid;\">" + count + "</td>" ) ;
   out.println ( "<td style=\"padding:4px;  border:1px #000000 solid;\">" + name + "</td>" ) ;
   out.println ( "<td style=\"padding:4px; border:1px #000000 solid;\">" + value + "</td></tr>" ) ;
  }
  
  count ++ ;
 }
 out.print ( "</table>" ) ;
}

 

// url 가져오기.
String requestURL = request.getRequestURL().toString();
String queryString = request.getQueryString();
if (queryString != null) requestURL += "?" + queryString;
out.print ( "<a OnClick=\"JavaScript:page_refresh('" + requestURL + "','.page_refresh');\">새로고침</a>" ) ;
%>


JSP Attribute 값

<%

session.setAttribute("tests","test");

Enumeration e = session.getAttributeNames();

int i=0;

out.println("<br><span style=\"font-size:12px;font-color:#EEEEEE;\"");

while(e.hasMoreElements()){

  String sname = (String) e.nextElement();

  String svalue = session.getAttribute(sname).toString();

  out.println("["+ i +"]"+sname+"=["+ i +"]"+svalue+"<br>");

  i++;

}

out.println("</span>");

%>


'DB & SQL & web' 카테고리의 다른 글

[jsp] 메일 보내기  (0) 2013.07.12
Apache James 설치 & PostgreSQL  (0) 2013.06.28
jQuery & ajax // PAGE 전환 없이 update.  (0) 2013.02.18
[PostgreSQL] INSERT INTO SELECT  (0) 2013.02.15
[jsp] long 쪼개기? 피식~  (0) 2013.02.02