package beans;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import link.Link;

import database.DBConn;

public class TagLink extends SimpleTagSupport {
	
	public void doTag()
	{
		int j=0;
		JspWriter out = getJspContext().getOut();
		ArrayList a = new DBConn().showLink();
		for(int i=0;i<a.size();i++)
		{
			if(j>3)
			{
				break;
			}
			
			Link link = (Link)a.get(i);
			try {
				out.print("<div align='left'>"+"&nbsp;&nbsp;&nbsp;<img src='images/dtxwan.gif'/>"+"&nbsp;&nbsp;<a href=\""+link.getAddr()+"\" target='_blank'>"+link.getTitle()+"</a><br></div>");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			j++;
		}
	}

}
