Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

packageless classes and jsp

 
JohnWilliam Fitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

If I make a little packageless class and put it directly in WEB-INF classes, I seem to be unable to call it from jsp. Is there something that prevents jsp's from using packageless classes (or should I say classes in the default package)? (Below is an example.)

//my packageless class
public class P284 {
public static String hi() {
return "hi";
}
}


<!-- my jsp -->
<% out.println(P284.hi()); %>

/* <!-- ERROR IN BROWSER...
An error occurred at line: 1 in the jsp file: /p284.jsp
P284 cannot be resolved
1: <% out.println(P284.hi()); %>
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, packageless classes (default package) will cause you problems.
Don't use them... :-)
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!