package edu.inspuruptec.su02.utils;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
public class TagConfig extends TagSupport{
private String words;
private String fontcolor;
public String getFontcolor() {
return fontcolor;
}
public void setFontcolor(String fontcolor) {
this.fontcolor = fontcolor;
}
public String getWords() {
return words;
}
public void setWords(String words) {
this.words = words;
}
@Override
public int doStartTag() throws JspException {
// TODO Auto-generated method stub
System.out.println("start call TagConfig.....doStartTag()....");
JspWriter out=this.pageContext.getOut();
HttpServletRequest htr=(HttpServletRequest)pageContext.getRequest();
String pass=htr.getContextPath();
Date date=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy MM dd hh:mm:ss");
String currenttime=sdf.format(date);
try {
out.print("<span><font color='"+this.fontcolor+"'>"+"当前系统时间是"+currenttime+" 当前路径是"+pass+"你输入的问候语是:"+this.words+"</front></span>");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return this.EVAL_BODY_INCLUDE;
//return this.SKIP_BODY;//它很没用。
}
@Override
public int doEndTag() throws JspException {
// TODO Auto-generated method stub
return EVAL_PAGE;
//return SKIP_PAGE;//跟在他后面要倒霉
}
/*public int doStartTag(){
System.out.println("start call TagConfig.....doStartTag()....");
JspWriter out=this.pageContext.getOut();
HttpServletRequest htr=(HttpServletRequest)pageContext.getRequest();
String pass=htr.getContextPath();
try {
out.print("当前路径是"+pass);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return this.EVAL_BODY_INCLUDE;
}
public int doEndTag() throws JspException {
// TODO Auto-generated method stub
return EVAL_PAGE;
}*/
}