Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to access a local class in jsp  RSS feed

 
Vickey singh Verma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem here with file Pjsp.jsp the code is as below

<% Person p= (person)request.getAttribute("person");%>
Person is:<%=p.getName()%>
Person is my local class stored in default package but I get a run time error as:



can anyone suggest me how to use a object of this class.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aside from the fact that you shouldn't be putting Java code into a JSP, any beans referenced from a JSP must be in a package other than the default. This is covered in the JSP FAQ.
 
harilal ithikkat
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dude,
while you typecasting ..your typed as person instead of Person
hope the following will work as you need.......


 
Vickey singh Verma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for u'r replies.
I was just trying an example from head first JSP chapter, instead of doing manually I used Netbeans and put the java class (Person) in default package
when coding in JSP page I can see the class Person by pressing CLT+SPACE but i don't understand why it gives error on creating the object of the class i.e p.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use real words when posting to the forums. Abbreviations such as "u'r" in place of "your" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!