336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
    let modal = window.open('xxxx.html', 'modal')



      modal.open("about:blank","_self").close();



window 를 open 으로 팝업시


parent window 에서 강제로


다시 window 를 open 하면


child window 가 닫긴다.

JNA Error

Programming/JAVA,JSP 2018. 2. 27. 15:48 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

JNA Error













int hr = m_pObjectKey.CreateInstance(__uuidof(KeyObject));


해당 구문에서


CreateInstance 의 리턴 값이



%x : 80040154


%d : -2147221164


형태로 계속 리턴되는 경우








80040154 오류
















System.Runtime.InteropServices.COMExcetption : 80040154 오류로 인해 CLSID가 {100202C1-E260-11CF-AE68-00AA004A34D5}인 구성 요소의 COM 클래스 팩터리를 검색하지 못했습니다.


https://social.msdn.microsoft.com/Forums/vstudio/ko-KR/03d5a6bd-e256-492a-a72b-f011b971834e/80040154-?forum=visualcsharpko
















쉽게 말하면 해당 라이브러리의 DLL 파일의 경로를 찾을수 없어서


객체를 만들 수 없다는 이야기이다.



















1) regasm, regsrv 를 이용하여 재등록을 시도해 보고,







그래도 안된다면









2) regasm 의 경우 /codebase 옵션을 사용 해 보라






























336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Java 에서


notepad.exe 를



Runtime.getRuntime().exec , ProcessBuilder 로 실행하기







notepad.exe 를 특정 폴더로 복사하고




ProcessBuilder launcher = new ProcessBuilder();

launcher.redirectErrorStream(true);

launcher.command("\\\\192.168.10.17\\tt\\notepad.exe","\\\\192.168.10.17\\tt\\test.jsp");

p = launcher.start();

 

 

 

                                       

 

p = Runtime.getRuntime().exec("\\\\192.168.10.17\\tt\\notepad.exe \\\\192.168.10.17\\tt\\test.jsp", null );

                                        


이런 형태로 실행 할때,



notepad.exe 가 실행되지 않는경우



notepad.exe 가 존재하는 폴더에 ko-KR\notepad.exe.mui 파일도 system32에서 가져와서 두면 실행이 된다.






'Programming > JAVA,JSP' 카테고리의 다른 글

window.open('xxxx.html', 'modal') close  (0) 2019.03.06
JNA Error  (0) 2018.02.27
Java CreateProcess Error=2 AccessControlException  (0) 2017.02.28
Java Applet 설정  (0) 2017.02.28
Java SocketServer control Image, DBConnect, String  (1) 2016.10.28
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Java CreateProcess Error=2 AccessControlException 




Java 1.5 JRE 에서는 IOException CreatProcess Error=2 로 발생하고


Java 1.8 JRE 에서는 AccessControlException access denied java.io.FilePermission 으로 발생한다.






둘다, Java Permission 문제






Jre 경로에서


Jre*.*.*\lib\sercurity\java.policy 파일에




grant codeBase * {

*

}


grant {


        permission java.security.AllPermission; 를 추가하면 된다.

*

*

*

}

Java Applet 설정

Programming/JAVA,JSP 2017. 2. 28. 12:58 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Java Applet 설정





Java Applet 구동 시





Apache 서버에




AmitApplet.java 를 AmitJavaApplication.jar 로 Export(Java->JAR file) 한다.


package test.Amit;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Map;

import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class AmitApplet extends JApplet {

	public void init() {

		try {
			for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					javax.swing.UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (ClassNotFoundException ex) {
			java.util.logging.Logger.getLogger(AmitApplet.class.getName()).log(java.util.logging.Level.SEVERE, null,
					ex);
		} catch (InstantiationException ex) {
			java.util.logging.Logger.getLogger(AmitApplet.class.getName()).log(java.util.logging.Level.SEVERE, null,
					ex);
		} catch (IllegalAccessException ex) {
			java.util.logging.Logger.getLogger(AmitApplet.class.getName()).log(java.util.logging.Level.SEVERE, null,
					ex);
		} catch (javax.swing.UnsupportedLookAndFeelException ex) {
			java.util.logging.Logger.getLogger(AmitApplet.class.getName()).log(java.util.logging.Level.SEVERE, null,
					ex);
		}
		// 

		try {
			java.awt.EventQueue.invokeAndWait(new Runnable() {
				public void run() {
					initComponents();
				}
			});
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	private void initComponents() {

		// String defaultCmd = "\\\\192.168.10.17\\tt\\notepad.exe";
		final String defaultCmd = "notepad.exe test.jsp";
		commandTextField = new JTextField();
		logTextArea = new JTextArea();
		runtimeButton = new JButton("getRuntime");
		processBuilderButton = new JButton("processBuilder");
		JPanel topPanel = new JPanel();

		setLayout(new BorderLayout());

		topPanel.setLayout(new GridLayout(4, 1));
		topPanel.add(new JLabel("Command"));
		topPanel.add(commandTextField);
		topPanel.add(runtimeButton);
		topPanel.add(processBuilderButton);
		add(BorderLayout.NORTH, topPanel);
		add(BorderLayout.CENTER, logTextArea);

		runtimeButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				if (commandTextField.getText().length() == 0) {
					try {
						Runtime.getRuntime().exec(defaultCmd);
					} catch (Exception e1) {
						// TODO Auto-generated catch block
						logTextArea.setText(e1.getMessage());
						e1.printStackTrace();
					}
				} else {
					try {
						Runtime.getRuntime().exec(commandTextField.getText());
					} catch (Exception e1) {
						// TODO Auto-generated catch block
						logTextArea.setText(e1.getMessage());
						e1.printStackTrace();
					}
				}
			}
		});
		processBuilderButton.addActionListener(new ActionListener() {
			public synchronized void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				if (commandTextField.getText().length() == 0) {

					try {
						ProcessBuilder launcher = new ProcessBuilder();
						Map environment = launcher.environment();
						launcher.redirectErrorStream(true);
						launcher.directory(new File("\\\\192.168.10.17\\tt\\"));

						// environment.put("test.jsp", defaultCmd);
						launcher.command("notepad.exe");
						Process p = launcher.start(); // And launch a new
														// process

					} catch (Exception e2) {
						logTextArea.setText(e2.getMessage());
						e2.printStackTrace();
					}
				} else {
					try {
						ProcessBuilder pb = new ProcessBuilder(commandTextField.getText());
						pb.start();

					} catch (Exception e1) {
						// TODO Auto-generated catch block
						logTextArea.setText(e1.getMessage());
						e1.printStackTrace();
					}
				}
			}
		});
	}

	@SuppressWarnings("unchecked")
	public void launchScript(String cmd, String args) {
		try {
			System.out.println("args value : = " + args);
			System.out.println("cmd value : = " + cmd);
			System.out.println("Full command:  = " + cmd + " " + args);
			if (cmd != null && !cmd.trim().equals("")) {
				if (args == null || args.trim().equals("")) {
					final String tempcmd = cmd;
					AccessController.doPrivileged(new PrivilegedAction() {
						public Object run() {
							try {
								Runtime.getRuntime().exec(tempcmd);
							} catch (Exception e) {
								System.out.println("Caught exception in privileged block, Exception:" + e.toString());
							}
							return null; // nothing to return
						}
					});
					System.out.println(cmd);
				} else {
					final String tempargs = args;
					final String tempcmd1 = cmd;
					AccessController.doPrivileged(new PrivilegedAction() {
						public Object run() {
							try {
								Runtime.getRuntime().exec(tempcmd1 + " " + tempargs);
							} catch (Exception e) {
								System.out.println("Caught exception in privileged block, Exception:" + e.toString());
							}
							return null; // nothing to return
						}
					});
					System.out.println(cmd + " " + args);
				}
			} else {
				System.out.println("execCmd parameter is null or empty");
			}
		} catch (Exception e) {
			System.out.println("Error executing command --> " + cmd + " (" + args + ")");
			System.out.println(e);
		}
	}

	JButton runtimeButton;
	JButton processBuilderButton;
	JTextField commandTextField;
	JTextArea logTextArea;
}






test.jsp 를 준비한다.




<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <title>My first WebApplication using NetBeansIDE</title>

    </head>

    <body>

        <h1>Hello World!</h1>

        <br />

        <p>WebApplication using NetBeansIDE...</p>

        

        <!-- Embedding Applet -->

<applet code="test.Amit.AmitApplet" archive="AmitJavaApplication.jar" width="400" height="350"></applet>

    </body>

</html>









Apache 는 Apache 비트에 맞는 Java 를 연결시키고


Applet 은 32비트에서 돌아간다

(컴퓨터에 32비트 Java JRE가 설치되어 있어야한다.)








Apache ROOT 폴더의 구조






Config















336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Java SocketServer control Image, DBConnect, String




package com.tistory.tansanc;

import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

import javax.imageio.ImageIO;

class DBConnect {
	ResultSet rs = null;
	Connection conn = null;
	Statement stmt = null;
	public DBConnect() {
		try {
			String url = "jdbc:sqlserver://192.168.10.17:1433;DatabaseName=MSSQLSERVER";
			
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			conn = DriverManager.getConnection(url, "sa", "1234");
			stmt = conn.createStatement();
			

		} catch (Exception e) {

		}
	}

	public void finalize() {
		try {
			rs.close();
			stmt.close();
			conn.close();
		} catch (Exception e) {

		}
	}
}

class PerClientThread extends Thread {
	Socket s;
	static ArrayList socketArray = new ArrayList();
	static DBConnect dbc;
	
	public PerClientThread()
	{
		
	}
	@Override
	public void run() {
		// TODO Auto-generated method stub

		socketArray.add(s);
		BufferedReader br;

		
		try {
			br = new BufferedReader(new InputStreamReader(s.getInputStream()));
			String temp;
			while ((temp = br.readLine()) != null) {
				// DB Query
				if (temp.startsWith("select")) {
					
					try {
						dbc.rs = dbc.stmt.executeQuery("SELECT * FROM [dbo].[TESTDB]");

						while (dbc.rs.next()) {
							String field1 = dbc.rs.getString("Date");
							String field2 = dbc.rs.getString("FileName");
							System.out.println(field1);
							System.out.println(field2);

							java.sql.Blob blb = dbc.rs.getBlob("Image");
							byte[] imagebytes = blb.getBytes(0, (int) blb.length());
							BufferedImage theImage = ImageIO.read(new ByteArrayInputStream(imagebytes));

						}
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					temp = "SQL:" + temp;
					System.out.println(temp);
				}
				// Arduino
				else if (temp.startsWith("insert"))
				{
					
				}
				// Arduino
				else if (temp.startsWith("image"))
				{

			        int size = Integer.parseInt(br.readLine());
			        
			        DataInputStream inputStream = new DataInputStream(s.getInputStream());
			        
			        byte[] imageAr = new byte[size];
			        inputStream.read(imageAr, 0, size);

			        BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageAr));

			        System.out.println("Received " + image.getHeight() + "x" + image.getWidth() + ": " + System.currentTimeMillis());
			        ImageIO.write(image, "png", new File("C:\\test2.png"));


				}
				// Arduino
				else if (temp.startsWith("to"))
				{
					
				}
				System.out.print(s.getInetAddress() + " : ");
				System.out.println(temp);
				for (int i = 0; i < socketArray.size(); i++) {
					PrintWriter os = new PrintWriter(socketArray.get(i).getOutputStream(), true);
					os.print(s.getInetAddress() + " : ");
					os.println(temp);
				}
			}

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		super.run();
	}
}

public class Server {
	public static void main(String[] args) throws Exception {
 
		System.out.println("Server Side");
		ServerSocket ss = new ServerSocket(33333);
		Socket s;
		while (true) {
			s = ss.accept();
			PerClientThread pct = new PerClientThread();
			pct.s = s;
			pct.dbc = new DBConnect();
			pct.start();
		}

	}
}










Client.java
package com.tistory.tansanc;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;

class MyFrame extends JFrame {
	public static JTextArea textArea;
	JTextField textField;
	PrintWriter out;
	Socket s;

	public MyFrame() {
		textArea = new JTextArea();
		textField = new JTextField();
		add(BorderLayout.CENTER, textArea);
		add(BorderLayout.SOUTH, textField);
		textField.addActionListener(new FieldListener());
		setSize(300, 200);
		setTitle("채팅프로그램 Client");
		setVisible(true);
		// GUI를 설계한다.
	}

	class FieldListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			if (textField.getText().compareTo("image") == 0) {

				BufferedImage image;
				ByteArrayOutputStream byteArrayOutputStream = null;
				DataOutputStream os = null;
				try {
					image = ImageIO.read(new File("C:\\test.png"));
					byteArrayOutputStream = new ByteArrayOutputStream();
					ImageIO.write(image, "png", byteArrayOutputStream);
					os = new DataOutputStream(s.getOutputStream());
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				
				try {
					int size = byteArrayOutputStream.size();
					out.println("image");
					out.println(size);
					os.write(byteArrayOutputStream.toByteArray());
					os.flush();
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}

			} else {
				out.println(textField.getText());
				textField.setText("");
			}
			// 메세지 보내기
		}
	}
}

class SendThread extends Thread {
	PrintWriter out;

	public SendThread(PrintWriter out) {
		this.out = out;
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		super.run();
	}
}

class RecvThread extends Thread {
	BufferedReader in;

	public RecvThread(BufferedReader in) {
		this.in = in;
	}

	@Override
	public void run() {
		String temp;
		try {
			while ((temp = in.readLine()) != null) {

				MyFrame.textArea.setText(MyFrame.textArea.getText() + "\n" + temp);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

class ClientModule {
	MyFrame mFrame;
	SendThread mSendThread;
	RecvThread mRecvThread;
	Socket s;

	// 서버에 패킷을 보내는 Thread
	// 서버로부터 패킷을 받는 Thread
	public ClientModule() // 준비
	{

		try {
			s = new Socket("192.168.10.17", 33333);
			PrintWriter out = new PrintWriter(s.getOutputStream(), true);
			BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
			mFrame = new MyFrame(); // GUI 객체
			mFrame.s = s;
			mFrame.out = out;
			mSendThread = new SendThread(out);
			mRecvThread = new RecvThread(in);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	void start() // 시작
	{
		mSendThread.start();
		mRecvThread.start();
	}
}

public class Client {
	public static void main(String[] args) {
		ClientModule cm = new ClientModule();
		// 초기화 작업
		cm.start();
		// Thread.start();
	}
}





336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Get client IP, Location, Address using just JavaScript?





I would use a web service that can return JSON (along with jQuery to make things simpler). Below are all the free active IP lookup services I could find and the information they return. If you know of any more, then please add a comment and I'll update this answer.


db-ip.com

http://api.db-ip.com/addrinfo?api_key=<your_api_key>&addr=<your_ip_address>

Returns:

{
  "address": "116.12.250.1",
  "country": "SG",
  "stateprov": "Central Singapore",
  "city": "Singapore"
}

Limitations:

  • 2,500 requests per hour
  • Doesn't support JSONP callbacks
  • Requires IP address parameter

geobytes.com

$.getJSON('//gd.geobytes.com/GetCityDetails?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "geobytesforwarderfor": "",
  "geobytesremoteip": "116.12.250.1",
  "geobytesipaddress": "116.12.250.1",
  "geobytescertainty": "99",
  "geobytesinternet": "SA",
  "geobytescountry": "Saudi Arabia",
  "geobytesregionlocationcode": "SASH",
  "geobytesregion": "Ash Sharqiyah",
  "geobytescode": "SH",
  "geobyteslocationcode": "SASHJUBA",
  "geobytescity": "Jubail",
  "geobytescityid": "13793",
  "geobytesfqcn": "Jubail, SH, Saudi Arabia",
  "geobyteslatitude": "27.004999",
  "geobyteslongitude": "49.660999",
  "geobytescapital": "Riyadh ",
  "geobytestimezone": "+03:00",
  "geobytesnationalitysingular": "Saudi Arabian ",
  "geobytespopulation": "22757092",
  "geobytesnationalityplural": "Saudis",
  "geobytesmapreference": "Middle East ",
  "geobytescurrency": "Saudi Riyal",
  "geobytescurrencycode": "SAR",
  "geobytestitle": "Saudi Arabia"
}

Limitations:

  • 16,384 requests per hour
  • Returns the wrong location (I'm in Singapore, not Saudi Arabia)

geoplugin.com

$.getJSON('//www.geoplugin.net/json.gp?jsoncallback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "geoplugin_request": "116.12.250.1",
  "geoplugin_status": 200,
  "geoplugin_credit": "Some of the returned data includes GeoLite data created by MaxMind, available from <a href=\\'http://www.maxmind.com\\'>http://www.maxmind.com</a>.",
  "geoplugin_city": "Singapore",
  "geoplugin_region": "Singapore (general)",
  "geoplugin_areaCode": "0",
  "geoplugin_dmaCode": "0",
  "geoplugin_countryCode": "SG",
  "geoplugin_countryName": "Singapore",
  "geoplugin_continentCode": "AS",
  "geoplugin_latitude": "1.2931",
  "geoplugin_longitude": "103.855797",
  "geoplugin_regionCode": "00",
  "geoplugin_regionName": "Singapore (general)",
  "geoplugin_currencyCode": "SGD",
  "geoplugin_currencySymbol": "&#36;",
  "geoplugin_currencySymbol_UTF8": "$",
  "geoplugin_currencyConverter": 1.4239
}

Limitations:

  • 120 requests per minute

hackertarget.com

http://api.hackertarget.com/geoip/?q=<your_ip_address>

Returns:

IP Address: 116.12.250.1
Country: SG
State: N/A
City: Singapore
Latitude: 1.293100
Longitude: 103.855797

Limitations:

  • 50 requests per day
  • Only returns plain text
  • Requires IP address parameter

ip-api.com

$.getJSON('//ip-api.com/json?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "as": "AS3758 SingNet",
  "city": "Singapore",
  "country": "Singapore",
  "countryCode": "SG",
  "isp": "SingNet Pte Ltd",
  "lat": 1.2931,
  "lon": 103.8558,
  "org": "Singapore Telecommunications",
  "query": "116.12.250.1",
  "region": "",
  "regionName": "",
  "status": "success",
  "timezone": "Asia/Singapore",
  "zip": ""
}

Limitations:

  • 150 requests per minute

ipify.org

$.getJSON('//api.ipify.org?format=jsonp&callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "ip": "116.12.250.1"
}

Limitations:

  • None (unlimited bandwidth)

ipinfo.io

$.getJSON('//ipinfo.io/', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "ip": "116.12.250.1",
  "hostname": "No Hostname",
  "city": "Singapore",
  "region": "",
  "country": "SG",
  "loc": "1.2931,103.8558",
  "org": "AS3758 SingNet"
}

Limitations:

  • 1,000 requests per day

ipinfodb.com

$.getJSON('//api.ipinfodb.com/v3/ip-city/?key=<your_api_key>&format=json&callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "statusCode": "OK",
  "statusMessage": "",
  "ipAddress": "116.12.250.1",
  "countryCode": "SG",
  "countryName": "Singapore",
  "regionName": "Singapore",
  "cityName": "Singapore",
  "zipCode": "048941",
  "latitude": "1.28967",
  "longitude": "103.85",
  "timeZone": "+08:00"
}

Limitations:

  • Two requests per second
  • Requires registration to get your API key

ip-json

http://ip-json.rhcloud.com/json

Returns:

{
  "site": "http://ip-json.rhcloud.com",
  "city": "Singapore",
  "region_name": null,
  "region": "00",
  "area_code": 0,
  "time_zone": "Asia/Singapore",
  "longitude": 103.85579681396484,
  "metro_code": 0,
  "country_code3": "SGP",
  "latitude": 1.2930999994277954,
  "postal_code": null,
  "dma_code": 0,
  "country_code": "SG",
  "country_name": "Singapore",
  "q": "116.12.250.1"
}

Limitations:

  • Quota not stated, but may be limited by OpenShift PaaS
  • Doesn't support JSONP callbacks

jsonip.com

$.getJSON('//jsonip.com/?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "ip": "116.12.250.1",
  "about": "/about",
  "Pro!": "http://getjsonip.com"
}

Limitations:

  • None (unlimited bandwidth)

jsontest.com

$.getJSON('//ip.jsontest.com/?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

Returns:

{
  "ip": "116.12.250.1"
}

Limitations:

  • Goes down a lot (over quota), so I wouldn't use it for production

snoopi.io

http://api.snoopi.io/v1/

Returns:

{
  "remote_address": "116.12.250.1",
  "requested_address": "116.12.250.1",
  "requested_time": "11:25:35 pm",
  "requested_date": "January 31, 2016",
  "CountryCode": "SG",
  "Region": null,
  "Region_Full": "Singapore",
  "City": "Ubi",
  "PostalZip": "96940",
  "TimeZone_Name": "Asia\/Singapore",
  "Latitude": "1.31865",
  "Longitude": "103.894"
}

Limitations:

  • 2,500 requests per day
  • Doesn't support JSONP callbacks


'Programming > JAVA,JSP' 카테고리의 다른 글

Java Applet 설정  (0) 2017.02.28
Java SocketServer control Image, DBConnect, String  (1) 2016.10.28
Web Browser 점유율 통계  (0) 2016.04.18
Activex Event use in JavaScript  (0) 2016.04.14
JDBC Realm  (1) 2016.03.09

Web Browser 점유율 통계

Programming/JAVA,JSP 2016. 4. 18. 10:40 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Web Browser 점유율 통계




이런식으로 WebBrowser 점유율 통계를 


브라우저 별, 버전 별 그래프로 보여준다.




그리고 각 버전별 지원하는 기능들도 보여준다.



위 그래프는 WebWorkers 를 지원하는 브라우저를 확인 할 수 있다.





출처 : 

http://caniuse.com/#search=worker

'Programming > JAVA,JSP' 카테고리의 다른 글

Java SocketServer control Image, DBConnect, String  (1) 2016.10.28
Get client IP, Location, Address using just JavaScript?  (0) 2016.04.26
Activex Event use in JavaScript  (0) 2016.04.14
JDBC Realm  (1) 2016.03.09
ImageFrameTest  (0) 2016.02.05

Activex Event use in JavaScript

Programming/JAVA,JSP 2016. 4. 14. 11:26 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

If you want to use Activex Event in JavaScript 



You commonly use JavaScript Event listener


1.  

<script type="text/javascript" for="ActiveXControl" event="LogOn()"></script>


2.   

var ctrl = document.getElementById("ActiveXControl");

ctrl.attachEvent('LogOn', ActiveXControl_LogOn);


function ActiveXControl_LogOn() {

        

}


3.   

var ctrl = document.getElementById("ActiveXControl");

ctrl.addEventListener('LogOn', ActiveXControl_LogOn, false);



function ActiveXControl_LogOn() {

        

}



This way can't use correctly alert method. you can see alert only in debug mode.


I think this situation is have a thread problem.



I suggest other way to use eventhandling


By use timer, This problem can be solved.



// make eventArray 

var eventArray = [];


// if event occured, when you add information to eventArray

eventArray.push(information);


// make Timer

setInterval(function () {

if (eventArray.length > 0) {

var information= eventArray.pop();

alert("information: " + information);

}

}, 100);



This method can be use alert method







'Programming > JAVA,JSP' 카테고리의 다른 글

Get client IP, Location, Address using just JavaScript?  (0) 2016.04.26
Web Browser 점유율 통계  (0) 2016.04.18
JDBC Realm  (1) 2016.03.09
ImageFrameTest  (0) 2016.02.05
Java 채팅 프로그램  (0) 2016.02.04

JDBC Realm

Programming/JAVA,JSP 2016. 3. 9. 14:16 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

테이블 생성


CREATE TABLE Users (

 username VARCHAR ( 25 ) NOT NULL,

 password VARCHAR ( 25 ) NOT NULL,

 enabled  VARCHAR ( 5 ) DEFAULT 'true',

 CONSTRAINT pk_users PRIMARY KEY (username)

);

 CREATE TABLE Authorities (

  username varchar(15) not null,

  authority varchar(15) not null,

  primary key (username, authority)

);


테이블을 만들고, 데이터를 입력한 뒤에 Spring의 context 설정을 변경한다.

테이터 입력시 주의할 점은 authority 컬럼 값으로 사용할 Role 에 대한 문자열은

대소문자를 구별하기 때문에 이를 유의해야 할 필요가 있다.

일반적으로 ROLE_ 을 접두어로 많이 쓰기 때문에

대문자로 입력하는 것이 좋을 것 같다.


INSERT INTO USERS VALUES('younghoe', 'info', 'true');

INSERT INTO AUTHORITIES VALUES('younghoe', 'ADMIN');


테이블 구조가 위와 같으면 별다른 설정이 필요없다.

테이블 구조가 다르면.. 프로퍼티 설정 변경만으로 수정이 가능하지만

ORM 도구로 JDBC 를 대신하려고 하는 경우는 코드 수정이 필요할 것이다.

 


<!-- UserDetailsService  -->

<bean id="jdbcDaoImpl" 

         class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl">

   <property name="dataSource"><ref bean="dataSource"/></property>

   <property name="rolePrefix" value="ROLE_" />

</bean>

 

물론 dataSource 에 대한 정의가 spring-context 어딘가엔 정의되어 있어야 한다.

 

<bean id="dataSource"

         class="org.apache.commons.dbcp.BasicDataSource"

         destroy-method="close">

   <property name="driverClassName" value="${jdbc.driverClassName}" />

   <property name="url" value="${jdbc.url}" />

   <property name="username" value="${jdbc.username}" />

   <property name="password" value="${jdbc.password}" />

</bean>

 

UserDetailsService  구현 클래스를 변경했으니

이를 사용하는 daoAuthenticationProvider 의 프로퍼티 값도 변경해야 한다.

 

<!-- DAO Authentication Provider -->

<bean id="daoAuthenticationProvider"

         class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">

    <property name="userDetailsService" ref="jdbcDaoImpl" />

</bean>

 

이제 메모리 Map 대신에 JDBC 를 사용하여 인증을 수행할 수 있다.


<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>jdbcRealm</realm-name>
    <form-login-config>
        <form-login-page>/login.xhtml</form-login-page>
        <form-error-page>/login.xhtml</form-error-page>
    </form-login-config>
</login-config>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>Secure Pages</web-resource-name>
        <description/>
        <url-pattern>/admin/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>ADMINS</role-name>
    </auth-constraint>
</security-constraint>
<security-role-mapping>
    <role-name>USERS</role-name>
    <group-name>USERS</group-name>
</security-role-mapping>
<security-role-mapping>
    <role-name>ADMINS</role-name>
    <group-name>ADMINS</group-name>
</security-role-mapping>


'Programming > JAVA,JSP' 카테고리의 다른 글

Web Browser 점유율 통계  (0) 2016.04.18
Activex Event use in JavaScript  (0) 2016.04.14
ImageFrameTest  (0) 2016.02.05
Java 채팅 프로그램  (0) 2016.02.04
Java 채팅 소스 예제 #1  (0) 2016.02.04