Filed under JSP, JAVA

1. Servlet 3.1 deployment descriptor

Java EE 7 XML schema, namespace is

<web-app xmlns="" xmlns:xsi="" xsi:schemaLocation="" version="3.1">

2. Servlet 3.0 deployment descriptor

Java EE 6 XML schema, namespace is

<web-app xmlns="" xmlns:xsi="" xsi:schemaLocation="" version="3.0">

3. Servlet 2.5 deployment descriptor

Java EE 5 XML schema, namespace is

<web-app xmlns="" xmlns:xsi="" xsi:schemaLocation="" version="2.5">



4. Servlet 2.4 deployment descriptor

J2EE 1.4 XML schema, namespace is

<web-app xmlns="" xmlns:xsi="" xsi:schemaLocation="" version="2.4">

  <display-name>Servlet 2.4 Web Application</display-name>

5. Servlet 2.3 deployment descriptor

J2EE 1.3 DTDs schema. This web.xml file is too old, highly recommend you to upgrade it.

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "" >

  <display-name>Servlet 2.3 Web Application</display-name>


2016/03/23 15:54 2016/03/23 15:54

Filed under C#


public static void SaveJpeg(string path, Image img, int quality)
            if (quality < 0 || quality > 100)
                throw new ArgumentOutOfRangeException("quality must be between 0 and 100.");

            // Encoder parameter for image quality
            EncoderParameter qualityParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
            // JPEG image codec
            ImageCodecInfo jpegCodec = GetEncoderInfo("image/jpeg");
            EncoderParameters encoderParams = new EncoderParameters(1);
            encoderParams.Param[0] = qualityParam;
            img.Save(path, jpegCodec, encoderParams);

        /// <summary>
        /// Returns the image codec with the given mime type
        /// </summary>
        private static ImageCodecInfo GetEncoderInfo(string mimeType)
            // Get image codecs for all image formats
            ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();

            // Find the correct image codec
            for (int i = 0; i < codecs.Length; i++)
                if (codecs[i].MimeType == mimeType)
                    return codecs[i];

            return null;

2016/03/04 10:58 2016/03/04 10:58
Filed under nginx
다음과 같은 오류가 발생한다면, 버퍼 사이즈를 nginx에 설정 해줘야한다.

20xx/xx/xx xx:xx:xx [warn] ….an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/xxxx while readi
ng upstream, client:, server:, request: “GET /font/NanumGothic-Regular.woff HTTP/1.1”, upstream: “http:

http, location , server 중 아무데나 아래 값 추가 할 수 있음.
location에 추가함 .

proxy_buffering   on;
proxy_buffer_size    1024k;
proxy_buffers        1024   1024k;
2016/02/24 09:54 2016/02/24 09:54

Filed under C#


a =(int)Convert.ToDouble("1.2");

Note if you're using comma as a number separator in your operating system, you have to use IFormatProvider:

var a =(int)Convert.ToDouble("1.2",CultureInfo.InvariantCulture.NumberFormat);

Another way to accomplish this task:

var a =int.Parse("1.2".Split('.')[0]);

2016/02/12 18:38 2016/02/12 18:38
Filed under C#
I found this solution to work for me when trying to access a file share on another computer.  It basically simulates doing a NET USE command where you can specify the credentials to use on the remote end.  The nice part is that you do not have to impersonate the user and it works across domains and workgroup computers.

First, declare these functions and types in your class.

using System.Reflection;
using System.Runtime.InteropServices;
using System.ComponentModel;

public class YourClass {
private static extern int WNetAddConnection2A(ref NetResource pstNetRes, string psPassword, string psUsername, int piFlags);
private static extern int WNetCancelConnection2A(string psName, int piFlags, int pfForce);

private struct NetResource {
    public int iScope;
    public int iType;
    public int iDisplayType;
    public int iUsage;
    public string sLocalName;
    public string sRemoteName;
    public string sComment;
    public string sProvider;

private const int RESOURCETYPE_DISK = 0x1;

Then, add these two methods.
    private void LoginToShare(string serverName, string shareName, string user, string password) {
        string destinationDirectory = string.Format(@"\\{0}\{1}", serverName, shareName);

        NetResource nr = new NetResource();
        nr.iScope = 2;
        nr.iType = RESOURCETYPE_DISK;
        nr.iDisplayType = 3;
        nr.iUsage = 1;
        nr.sRemoteName = destinationDirectory;
        nr.sLocalName = null;

        int flags = 0;
        int rc = WNetAddConnection2A(ref nr, password, user, flags);

        if (rc != 0) throw new Win32Exception(rc);

    private void LogoutFromShare(string serverName, string shareName) {
        string destinationDirectory = string.Format(@"\\{0}\{1}", serverName, shareName);
        int flags = 0;
        int rc = WNetCancelConnection2A(destinationDirectory, flags, Convert.ToInt32(false));

In your code, call the LoginToShare with the server, share, user, and password needed.  Then simply use the standard \\server\share\path conventions for accessing files on remote computers.  Call the LogoutFromShare when you're done.

2016/01/26 10:05 2016/01/26 10:05
Filed under spring framework
[출처] :
classCombinedCommand(){Activity activity;Etabl etabl;//Getter and setter}


  method="post" commandName="combinedCommand"">...<form:input type="text"path="activity.x"/>...<form:input type="text"path="etabl.y"/>...</form:form>
2015/12/14 11:24 2015/12/14 11:24
Filed under JSP, JAVA

자바 Math 클래스에서 실수값 반올림이나 올림, 버림, 절대값을 구해주는 메서드가 있다.

static long Math.round(double a)
static int Math.round(float a)
예) System.out.println(Math.round(100.56)); //결과: 101

static double ceil(double a)

예) System.out.println(Math.ceil(100.56)); //결과: 101.0

static double floor(double a)

예) System.out.println(Math.floor(100.56)); //결과: 100.0

static double abs(double a)
static float abs(float a)
static int abs(int a)
static long abs(long a)

예) System.out.println(Math.abs(-100.56)); //결과: 100.56

참고로 소수 둘째자리에서 반올림을 하고 싶다고 하면 아래와 같이 응용한다.

double a = 100.22516;
double b = Math.round(a*100d) / 100d;
System.out.println(b); //결과: 100.23

원리는 차근차근 따라해 보면 쉽다.
일반 round() 메서드는 소수첫째자리에서 반올림 되기때문에 내가 반올림 하고자하는 자리수가 첫번째 소수점자리가 되도록 10 제곱을 곱해준다.
즉, 소수 2번째 자리까지 구하기 때문에 a에 10^2 하게되면 10022.516이 된다.
여기에서 반올림 한후 다시 나눈만큼 곱해주면 원래 소수 자리로 복원되게 된다.

다른 방법으로는 서식출력이 가능한 표준출력 메서드를 이용한 방법이다.
double a = 100.22516;
System.out.printf("%.2f",a); //결과 100.23

소수 둘째자리 실수로 반올림하여 출력하는 메서드이다.

간단한 내용이면서도 자주 활용되는 메서드에 대해 정리해보았습니다.
2015/12/03 16:14 2015/12/03 16:14
Filed under JSP, JAVA

 * Pathvariable example
 * @return
public String page(@PathVariable String var){
    String returnUrl = "";
    if(var.equals("one")) {
        returnUrl = "page1";
    } else if(var.equals("two")) {
        returnUrl = "page2";
    return returnUrl;
2015/11/18 17:46 2015/11/18 17:46
Filed under Linux
스프링의 web.xml에 utf-8 filter 를 추가 해주고도  한글이 께진다면 
tomcat 서버의 다음과 같이 설정을 해주면 한글 깨짐을 방지 할 수 있다.


 <Connector port="8080" protocol="HTTP/1.1"
               redirectPort="8443" URIEncoding="UTF-8"  />

2015/11/10 10:03 2015/11/10 10:03
Filed under PHP
foreach($_REQUEST as $key => $value ){
  ${"$key"} = $value;
2015/11/04 18:01 2015/11/04 18:01