Skip to content

Instantly share code, notes, and snippets.

@shinchit
shinchit / checkdate.html
Last active August 29, 2015 14:02
HTMLフォームに入力された日付(年月日)が現在日付(年月日)より過去に指定されているかどうか調べるJavaScript(+HTML)のサンプルHTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="./js/checkdate.js"></script>
</head>
<body>
<form action="xxx.do">
<select id="year">
<option>2013</option>
@shinchit
shinchit / checkdate.js
Created June 20, 2014 12:58
HTMLフォームに入力された日付(年月日)が現在日付(年月日)より過去に指定されているかどうか調べるJavaScript(jQuery使用)
$(function() {
// 1.現在日付(時分秒はゼロにセットする)を得る
var now = new Date();
now = new Date(now.getFullYear(), now.getMonth(), now.getDate());
// 2.フォームで指定された日付を得る
var year = $("#year");
var month = $("#month");
var day = $("#day");
@shinchit
shinchit / gist:418126ab5fc1edc55720
Last active August 29, 2015 14:03
JSPで<html:〜>のタグの解析結果(HTML)にIDを指定する方法 -サンプル
<html:text property="address" styleId="address_id"/>
(生成されるhtmlコード)
<input type="text" name="address" id="address_id"/>
@shinchit
shinchit / gist:756b1935de44eb20f064
Last active August 29, 2015 14:03
JSP、Servletのバージョンを確認するJSP
JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %><br>
Servlet Specification: <%= application.getMajorVersion() %>.<%= application.getMinorVersion() %><br>
<c:choose>
<c:when test="${someObj.strStatus == '0'}">
<!-- someObj.strStatusの値が0の時-->
ステータスは0(無効)です。
</c:when>
<c:otherwise>
<!-- someObj.strStatusの値が0ではない時-->
  ステータスは<bean:write name="someObj" property="strStatus"/>0以外(有効)です。
</c:otherwise>
</c:choose>
@shinchit
shinchit / gist:26fb8e0e0c41a8dd8c03
Last active August 29, 2015 14:03
Javaによる出力文字コードの指定
// リクエストボディの文字コードを特定のコード(ここではShift_JIS)に指定
request.setCharacterEncoding("Shift_JIS");
// レスポンス(サーバの出力文字列)の文字コードとレスポンスヘッダを特定のコード(ここではShift_JISに指定)
response.setContentType("text/html; charset=Shift_JIS");
@shinchit
shinchit / gist:444552b1fbb3e317d058
Last active August 29, 2015 14:03
Javaによる文字コードの指定(Servlet Filter使用)
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CharacterEncodingFilter implements Filter {
  private String encoding = null;
// このクラスが初めて実行される時のみ一度だけコールされるメソッド。初期化に使う。
// マルチスレッドの環境においては、最初のスレッドがこのクラスを呼び出した時のみ実行される。
  @Override
@shinchit
shinchit / gist:4a89a2e67b565daf20ba
Last active August 29, 2015 14:03
Servletにおけるweb.xmlでの文字コードの設定例
<!-- フィルタ名とそのクラスを指定し、初期化に使うパラメータもinit-paramタグで指定する -->
<filter>
  <filter-name>Character Encoding</filter-name>
  <filter-class>mysedlf.filter.CharacterEncoding</filter-class>
  <init-param>
    <param-name>encoding</param-name>
    <param-value>Shift_JIS</param-value>
  </init-param>
</filter>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://raw.githubusercontent.com/padolsey/jquery.fn/master/cross-domain-ajax/jquery.xdomainajax.js"></script>
<script type="text/javascript">
var uri = 'http://example.xxx'; // 取得対象のURIを指定
$.get(uri, function(res){
// 取得したデータのbodyタグの中身を抜き出す。
var body = $(res.responseText).find('body').text() ;
alert(body);
});
</script>
@shinchit
shinchit / gist:59fd90f226dc7977e1db
Last active August 29, 2015 14:05
Excel VBA(マクロ)で値が入っている最下セルの一つ下のセルを選択状態にする方法
' 途中に空白のセルがあった場合でも最下セルを選択できる方法。
' 1行目から探索する方法ではなく、Excelシートの定義上の最下行("A65535")から上に遡る方法を使う。
' 例ではx列(xには任意の列番を指定)で値が入っている最下セルの一つ下のセルを選択する
Dim x As Integer
x = 2 ' 2列目をターゲットにする
Range("A65535", x).End(xlUp).Offset(1, 0).Activate