view src/myVncProxy/CreateHtmlFile.java @ 33:e44ffe36c514

update CreteHostFile
author e085711
date Wed, 27 Apr 2011 06:12:13 +0900
parents 015d43bb2b62
children 8d8e63b3bd83
line wrap: on
line source

package myVncProxy;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.net.InetAddress;

public class CreateHtmlFile {

	String header="<HTML><TITLE>hbpVNC desktop</TITLE>\n";
	String footer="<BR><A href=\"http://ie.u-ryukyu.ac.jp\"University of the Ryukyu </HTML>\n";

	String host;
	String user;
	int port;
	int width;
	int height;
	
	File file;
	
	MyRfbProto rfb;
	
	CreateHtmlFile(MyRfbProto _rfb, String _host, String _user){
		rfb = _rfb;
		host = _host;
		user = _user;
		port = rfb.getAcceptPort();
		width = rfb.framebufferWidth;
		height = rfb.framebufferHeight;

	}

	void createHtml(){
		try{
//			String html_file = "/var/www/html/hbpVNC/"+ user +".html";
			String html_file = "./"+ user +".html";
		    file = new File(html_file);
		    PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
		    
		    InetAddress addr = InetAddress.getLocalHost();
		    
		    String contents = "<APPLET CODE=\"VncViwer.class\" ARCHIVE=\"VncViewer.jar\"\n " +
					"WIDTH=\""+width+"\" HEIGHT=\""+height+"\">\n";
		    contents = contents+"<PARAM NAME=\"PORT\" VALUE=\""+port+"\">\n";
		    contents = contents+"<PARAM NAME=\"HOST\" VALUE=\""+addr.getHostAddress()+"\">\n";
		    
		    pw.println(header+contents+footer);
		    pw.close();
		}
		catch (Exception e) {
		    e.printStackTrace();
		}
	}
	
	
}