TLD to display Logo (Image)

Note: Put your Image Under the  (contextPath of your App/images/) folder

TLD FILE

<?xml version=”1.0″ encoding=”ISO-8859-1″ ?>
<!DOCTYPE taglib PUBLIC “-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN” “http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd”&gt;

<taglib>
<tlibversion>1.5</tlibversion>
<jspversion>1.1</jspversion>
<shortname>NetvertexSM</shortname>
<uri>http://https://javacircles.wordpress.com/myprojects/tags</uri&gt;
<info>I am JavaCirle</info>

<tag>
<name>logoImage</name>
<tagclass>com.raj.myproject.util.MyLogo</tagclass>
<bodycontent>empty</bodycontent>
<info>Logo Image</info>
</tag>

</taglib>

================================

CLASS FILE

—————–

 

package com.raj.myproject.util;
import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public class MyLogo extends TagSupport {
private static final long serialVersionUID = 1L;
private static final String MODULE = ElitecoreLogo.class.getSimpleName();

public int doStartTag() throws JspException {

JspWriter painter = pageContext.getOut();
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
StringBuffer results = new StringBuffer();
results.append(“<input type=\”image\” src=\””+request.getContextPath()+”/images/jisp.jpg\” width=\”101\”                                                         height=\”113\” />”);
try {
painter.write(results.toString());
} catch (IOException e) {
Logger.logError(MODULE, “Exception reason : “+e.getMessage());
e.printStackTrace();
}
return EVAL_PAGE;
}
}

Advertisements

About rajkirpal

i am a software engineer. and i have decent knowledge about java technologies like ANDROID, Servlet, Jsp, Struts, Hibernet, Spring, J2ME, Java Script, Ajax, JQuery, CSS. Further i am Preparing Easy understandable materials/documents upon the same java technologies and developing project in core java , advanced java and j2me , ANDROID as per the requirements Also designing the web sites and logos Thank You.
This entry was posted in J2EE. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s