Java Server Page

JSP Projects

JSP Project

Write a program that display Current status.
Previous Home Next
adplus-dvertising
Following program Save under the map give below.


<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
 http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">
<tlib-version>1.0</tlib-version>
<short-name>current_library</short-name>
<uri>/WEB-INF/tlds/current_library</uri>
<tag>
<name>Current</name>
<tag-class>r4r.co.in.CurrentTag</tag-class>
<body-content>scriptless</body-content>
<info>This tag is used for display Current items</info>
</tag>

</taglib>
Following java program is used for tag handling
save as a CurrentTag.java
Program is used for TagHandler
package r4r.co.in;
import javax.servlet.ServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
public class CurrentTag extends TagSupport {
@Override
public int doStartTag() throws JspException {
ServletRequest request = pageContext.getRequest();
String CurrentTag = request.getParameter("Current");
if ((CurrentTag )!= null) {
return EVAL_BODY_INCLUDE;
} else {
return SKIP_BODY;
}
}
}
Save as a Curent.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="/WEB-INF/tlds/current_library.tld"
prefix="current_library" %>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=UTF-8">
<title>r4r.co.in</title>
</head>
<body>
<%@page  import="java.util.*" %>
<current_library:Current>
</current_library:Current>
<B>Current Status:</B>
<ul>
<li> Current Date: <%= new java.util.Date()%>
<li> HostName: <%= request.getRemoteHost()%>
<li> Session ID: <%= request.getRequestedSessionId()%>
</ul>
</body>
</html>
Output:
Previous Home Next