• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

How to Import a JAVA File in JSP

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have written a statement :<%@ page import="MyBean.java" %> in my JSP.
MyBean.java is my Bean class located in folder WebApps/EnterUserDataApp folder.
How to import this this java file so that i can use the getters and setters of this bean class within my JSP ?
I am doing a simple Servlet JSP application without using struts or tag libraries.
Please Help
 
Santosh Nijalingappa
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note: Forgot to mention I am using TomCat Server and my directory structure is as follows:
C:\apache-tomcat-5.5.17\webapps\EnterUserDataApp

Within this EnterUserDataApp folder i have my
WEB-INF folder and i am placing my JSP, Servlet and bean java file in EnterUserDataApp folder.
 
Sheriff
Posts: 67735
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please see the JSP FAQ entries. They will explain where you must place your class files.
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compile MyBean.java class and place compiled class (MyBean.class) into WEB-INF folder of your application.

Also, must look at the directory structure of application deployed on tomcat.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note that the import attribute takes neither a source file name nor a class file name, but a class name. That would be MyBean in your case, plus the appropriate package name in front of it.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
Note that the import attribute takes neither a source file name nor a class file name, but a class name. That would be MyBean in your case, plus the appropriate package name in front of it.



Yep. I missed that.
 
You get good luck from rubbing the belly of a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic