jsp에서 한글이 깨지는 것때문에 공부하게 되는 팁~~^^

이미 이런 jsp 베스트 프랙티스라 해서 사용하고 있는데...  굳이 코딩하거나 고민하지 않아도 된다는거....(살짝은 재미없다.)

그러나 나에게는 편하다라는 것~^^

 

 

발췌

JSP best practices: Import content to your Web site

http://www.ibm.com/developerworks/java/library/j-jsp06173.html

 

이 문서를 보면 다음과 같다.

 

 

Importing external content

One of the real advantages of using c:import is its ability to pull in content from external Web sites or Web applications. Back when you were learning about jsp:includes, you may have noticed that we used file attributes to designate static content to include. The file attribute does just what its name implies: it allows you to pull in a local file's content. The corresponding attribute for c:import is url, and it too does what its name suggests: it allows you to pull in any URL. Rather than just populating your site pages with content from local files, c:import lets you pull in content from any URL, which is essentially a really slick way to wrap content from other sites in your own look and feel.

Let's consider a simple example. Say I want to place some pictures of a gorgeous Madagascar Rosewood guitar on my Web site. While I could build my own page, complete with image files and relative links, it seems much easier to simply import the content from another site, then wrap it up in my site's look and feel. Listing 3 shows how easy it would be to use c:import's url attribute to pull in image files from my favorite guitar site:


Listing 3. Importing external content
<%@ page language="java" contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head>
     <title>newInstance.com</title>
     <meta http-equiv="Content-Type" 
       content="text/html; charset=iso-8859-1" />
     <link href="/styles/default.css" rel="stylesheet" type="text/css" />
</head>

<body>

<c:import url="header.jsp">
     <c:param name="pageTitle" 
       value="newInstance.com :: True North Guitars"/>
     <c:param name="pageSlogan" value="...building it from scratch" />
</c:import>
<%@ include file="/navigation.jsp" %>
<c:import url="bookshelf.jsp" />

<c:import 
  url="http://www.truenorthguitars.com/Clients/Richman/index.htm" />

<%@ include file="/footer.jsp" %>
</body>
</html>

The code looks good enough -- but if you try this out on your own, you'll quickly see a problem. None of the images show up and all of the relative links fail. Of course, if you think about it, the cause is perfectly clear. Because the external resource (in this case an image file) is interpreted, you get the result of that interpretation inserted directly into your output stream. External image links like /images/guitar-01-24.jpg will show up as missing. The only way to resolve this problem would be to copy the image to your site, which is an entirely different (and more time consuming) technique as compared to a simple import.

So importing external content really only makes sense if the content is purely text-based. For example, consider a site geared toward system administrators, with its own header, footer, and look and feel. One page of the site details how to set up an initial README file for users to see how the site should be used. You could refer to an existing FTP site's instructions as follows:

<c:import url="ftp://ftp.oreilly.com/pub/README.ftp" />

Notice that it's just as simple to import FTP server content as it is to pull in HTTP material. You can use the same command for HTTPS, as well as any other protocol that both your site and the target site understand and speak.

 

 

설명을 달면, c:import는 외부 웹싸이트 정보 또는 웹 어플리케이션의 컨텐츠를 가져올 수 있다고 한다.

 

<c:import url="bookshelf.jsp" />

<c:import
  url="http://www.truenorthguitars.com/Clients/Richman/index.htm" />

<c:import url="ftp://ftp.oreilly.com/pub/README.ftp" />

 

 

이렇게 다양하게 사용가능하다고 한다.

 

'web' 카테고리의 다른 글

L4스위치와 L7스위치의 차이점  (0) 2007.09.29
자바 - include 관련  (1) 2007.09.28
외부 컨텐츠를 가져오는 법  (0) 2007.09.28
jsp에서 한글이 깨지는 현상  (0) 2007.09.28
SSL (c, java)  (0) 2007.09.28
아파치 래퍼럴 (apache referal)  (0) 2007.09.27
Posted by 김용환 '김용환'

댓글을 달아 주세요