• Post Reply Bookmark Topic Watch Topic
  • New Topic

How refer to classes in included JSP?  RSS feed

 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've included a JSP via the <jsp:include" command, so it allows the JSP to do actual coding, but I can't figure out how to refer to my custom classes.

I tried two things:

1. In main JSP (that calls <jsp:include) I included the proper import statements
2. In the included JSP, I put the import statements via <%@ import.

The first one failed, saying the classes could not be found in the included JSP. The second failed saying an invalid directive in the included page.

What do I do?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The included JSP is a separate unit from the parent, so nothing, including imports, will be "inhereted" from the parent.

If you want to avoid invalid directive errors, use the correct syntax for the directives.
 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
The included JSP is a separate unit from the parent, so nothing, including imports, will be "inhereted" from the parent.

If you want to avoid invalid directive errors, use the correct syntax for the directives.


Yes, i understand that. My question is: how do i import packages in my included file?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same way as you would in any other JSP file: with the appropriate directives. Included files are translated and compiled the same way as any standalone page.
[ October 27, 2006: Message edited by: Bear Bibeault ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!