Use of packages in JSP

How to use of packages in JSP? Given with example...


Java classes stored as packages can be effectivley used in JSP. Following is an example to explain the usage of Java Class.

Example: Example1.jsp

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page import="mypack.Display" %>
<%@taglib prefix="c" uri="" %>
Display cnt=new Display();
String outpt=cnt.echoVar("Hi da");

package mypack;
public class Display
public String echoVar(String var){
return var;

In the above example we have used a package "Counter" with a class "echovar". In the example we have created a new instance of the package "Counter" to use the class "echovar" to display the text input.

Ask Questions

Ask Question