-1

Wrote some code as a Java Servlet and I am now trying to use in JSP. I wrote a class in a separate file which I was using, and I can't figure out how to get the JSP file to recognise the class. I guess it has something to do with importing. I gave the class a default package (no name of package) and I tried using <%@ page import=".Register"%> but I get an error: (Register is my servlet class name..) so tell me what if i do to import of default package in jsp. Thanks for all your help!

Drejc
  • 14,196
  • 16
  • 71
  • 106

2 Answers2

1

You can't import a class from a default package. It's a compile time error. See the Java Specification.

Or you can use reflections. For Reflections You Can Visit SO link: Reflections for importing class from default package.

Community
  • 1
  • 1
Divya
  • 1,469
  • 1
  • 13
  • 25
0

Well I think you need to look up JSP Specification and I got idea that you need to specify the package name if you wanted to import into the JSP. I did not know until I read the document.

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
Kishan Bheemajiyani
  • 3,429
  • 5
  • 34
  • 68