tutorial on js
http://developers.sun.com/scripting/javascript/ajaxinaction/Ajax_in_Action_ApB.html
Tuesday, September 30, 2008
Friday, September 26, 2008
quacl.style.left=width/2.25;
quacl.style.top=height/2.5;
quacl.position="fixed";
Element.show('quacl');
function getScreenMiddleHeight(){
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3) {
screenH = screen.height;
}
else if (navigator.appName == "Netscape"
&& parseInt(navigator.appVersion)==3
&& navigator.javaEnabled()
)
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenH = jScreenSize.height;
}
return screenH/2;
}
function getScreenMiddleWidth(){
var screenW = 640;
if (parseInt(navigator.appVersion)>3) {
screenW = screen.width;
}
else if (navigator.appName == "Netscape"
&& parseInt(navigator.appVersion)==3
&& navigator.javaEnabled()
)
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenW = jScreenSize.width;
}
return screenW/2;
}
quacl.style.top=height/2.5;
quacl.position="fixed";
Element.show('quacl');
function getScreenMiddleHeight(){
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3) {
screenH = screen.height;
}
else if (navigator.appName == "Netscape"
&& parseInt(navigator.appVersion)==3
&& navigator.javaEnabled()
)
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenH = jScreenSize.height;
}
return screenH/2;
}
function getScreenMiddleWidth(){
var screenW = 640;
if (parseInt(navigator.appVersion)>3) {
screenW = screen.width;
}
else if (navigator.appName == "Netscape"
&& parseInt(navigator.appVersion)==3
&& navigator.javaEnabled()
)
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenW = jScreenSize.width;
}
return screenW/2;
}
Thursday, September 25, 2008
Tuesday, September 23, 2008
Tomcat datasource connection pooling
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#Non%20DBCP%20Solutions
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#Non%20DBCP%20Solutions
private static void initializeDataSource(String whichOne) throws NamingException, SQLException{
logger.debug("entering initializeDataSource("+whichOne+")");
try{
InitialContext ic = new InitialContext();
if(whichOne.equals(AppHelper.SC_DEFAULT_DS_CON)){
//if (dataSource == null)
dataSource = (DataSource) ic.lookup(whichOne);
}
}catch (NamingException ne){
throw new NamingException("NamingException while looking" +
" up DataSource Connection " + whichOne
+ ": \n" + ne.getMessage());
}
logger.debug("leaving initializeDataSource()");
}
Friday, September 19, 2008
Friday, September 12, 2008
creating a tld
public class myTag extends TagSupport{
}
mytag.tld
accessing in .jsp
public class myTag extends TagSupport{
}
mytag.tld
< taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0" -->
<-- description -->my excelent tag<--/ description -->
<-- display-name -->company taglib<--/ display-name -->
<-- tlib-version -->1.1<--/ tlib-version -->
<-- short-name -->mytag<--/ short-name -->
<-- uri -->http://java.sun.com/jsp/jstl/core<--/ uri -->
<-- tag -->
<-- description -->
my great tag
<--/ description -->
<-- name -->calendar<--/ name -->
<-- tag-class -->com.mypackage.Calendar<--/ tag-class -->
<-- body-content -->JSP<--/ body-content -->
<-- attribute -->
<-- description -->
the calendar obj
<--/ description -->
<-- name -->objname<--/ name -->
<-- required -->true<--/ required -->
<-- rtexprvalue -->true<--/ rtexprvalue -->
<--/ attribute -->
<--/ tag -->
<--/ taglib -->
accessing in .jsp
<%@ taglib uri="/WEB-INF/mytag.tld" prefix="mytag" %>
< mytag:calendar objname="myCalendar" />
Friday, September 05, 2008
http bot crawler
import org.htmlparser.Node;
import org.htmlparser.NodeFilter;
import org.htmlparser.Parser;
import org.htmlparser.filters.TagNameFilter;
import org.htmlparser.util.NodeList;
private void runCrawl(String url, String file)throws Exception{
URL crawlURL = new URL(url);
URLConnection yc = crawlURL.openConnection();
//sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
//String encodedUserPwd = encoder.encode("kg_b05"+":"+"*****");
//yc.setRequestProperty("Proxy-Authorization", "Basic " +encodedUserPwd);
InputStream i = yc.getInputStream();
FileOutputStream fos = new FileOutputStream(file);
int in=i.read();
while(in!=-1){
fos.write(in);
in=i.read();
}
fos.flush();
fos.close();
}
private String readFile(String file) throws Exception{
String str = "", html = "";
try {
BufferedReader in = new BufferedReader(new FileReader(file));
while ((str = in.readLine()) != null) {
html += str;
}
in.close();
} catch (IOException e) {
throw e;
}
return html;
}
public MegaVO doMegaTask() throws Exception{
runCrawl(SC_MEGA_URL, SC_MEGA_FILE);
String html = readFile(SC_MEGA_FILE);
Parser parser = new Parser();
parser.setInputHTML(html);
NodeFilter nf = new TagNameFilter("span");
NodeList spans = parser.parse (nf); // here is your two node list
Node span = null;
Node child = null;
String num = "", date = "", d1 = "", d2 = "", d3 = "", d4 = "", d5 = "", mm = "";
for(int i=0; i < spans.size(); i++){
span = spans.elementAt(i);
//if(span.getText().equals("span id=\"DrawResults2_lblMMNum1\"")){
String text = span.getText();
if(text.length() > 27){
if(text.substring(0,27).equals("span id=\"DrawResults2_lblMM")){ // 27 characters deep
String id = text.substring(27,text.length()-1);
child = span.getFirstChild();
if(id.equals("DrawNum")){
logger.info(child.getText());
num = child.getText();
}else if(id.equals("DrawDate")){
logger.info(child.getText());
date = child.getText();
}else if(id.equals("Mega")){
logger.info(child.getText());
mm = child.getText();
}else{
String n = id.substring(id.length()-1);
switch((new Integer(n)).intValue()){
case 1:
d1 = child.getText();
break;
case 2:
d2 = child.getText();
break;
case 3:
d3 = child.getText();
break;
case 4:
d4 = child.getText();
break;
case 5:
d5 = child.getText();
break;
}
logger.info(id);
logger.info(child.getText());
}
}
}
}
MegaVO vo = new MegaVO(num,date,d1,d2,d3,d4,d5,mm);
logger.info(vo.toString());
return vo;
}
Subscribe to:
Posts (Atom)