Respected Sirs,
I am trying to demonstrate the use of taglibs.
I wrote the following three files.
In which locations these files placed.Please check
these files and verify. And please
tell how to configure the 'web.xml' file.
sslCheck.java
***************8
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.TagSupport;
public class sslCheck extends TagSupport {
private
String errorpage=null;
public void setErrorpage(String errorpage) {
this.errorpage=errorpage;
}
public int doStartTag() throws JspException {
try {
HttpServletRequest request=(HttpServletRequest)pageContext.getRequest();
HttpServletResponse response=(HttpServletResponse)pageContext.getResponse();
if(request.getScheme().indexOf("https")==-1) {
if(errorpage!=null) {
// redirect to the error page
response.sendRedirect(errorpage);
} else {
// redirect to the page using ssl
String jumpURL="https://"+request.getServerName()+request.getRequestURI();
if(request.getQueryString()!=null) jumpURL+="?"+request.getQueryString();
response.sendRedirect(jumpURL);
}
return SKIP_PAGE;
}
} catch (IOException ioe) {
throw new JspTagException("sslcheck tag failed");
}
return EVAL_BODY_INCLUDE;
}
public int doEndTag() {
return EVAL_PAGE;
}
}
*******************************************
sslcheck.tld
***********
<?xml version="1.0" encoding="UTF-8"?>
<taglib>
<tlibversion>1.0</tlibversion>
<shortname>sslchk</shortname>
<info>Tag library for checking SSL</info>
<tag>
<name>sslcheck</name>
<tagclass>sslCheck</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>errorpage</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
************************************
ssl.jsp
*********
<%@ taglib prefix="sslchk" uri="/WEB-INF/jsp2/sslCheck.tld" %>
<sslchk:sslcheck/>
*******************************************************
if possible please tell the execution procedure breifly.
Thanks in advance
Regards Francis