0

I want to use a java class in JSP. I placed the java class file in WEB-INF/classes/hello.class.

In index.jsp i'm creating the object for hello class.

I'm getting this error "hello cannot be resolved to a type". Here is my jsp code,

<%@ page import="hello" %>
<%
    hello h = new hello();
    out.print(h.getValue());
%>
Ashish
  • 1,943
  • 2
  • 14
  • 17
sanjay Kumar
  • 140
  • 1
  • 14
  • Check your directory structure (i.e) whether you have your class in src package and also see to ur naming conventions . java classes Start with upper case – Santhosh Jan 10 '14 at 10:58
  • Must see [How to avoid Java Code in JSP-Files?](http://stackoverflow.com/q/3177733/1031945) – Aniket Kulkarni Jan 10 '14 at 11:12

3 Answers3

0

What does your class hello look like ? (BTW, you should uppercase it : Hello)

Anthed
  • 139
  • 1
  • 6
0

Hello Java class would be create under package. So while importing in jsp, use the complete path.

<%@ page import="com.abc.Hello" %>
0

u can add packages to get java class in side source packages create a package then u can import that class in jsp page

eg-

<%@page import="Ab.*"%>

ie source packages/Ab/hello.java