publicRavi
publicRavi

Reputation: 2763

JSP import Java class

When I try to call the method after importing the class, like below, I get method is undefined error.

<%@page import="td.TourHelper"%>
<%=getTourName()%>

But, when I directly call the method, it works.

<%=td.TourHelper.getTourName()%>

Any clues?

Upvotes: 0

Views: 3939

Answers (1)

Aravind Yarram
Aravind Yarram

Reputation: 80166

Change

<%=getTourName()%>

to

<%=TourHelper.getTourName()%>

The first option will work if your container supports static imports provided you change the page directive as below

<%@page import="static td.TourHelper"%>

Upvotes: 2

Related Questions