Solved

jsp method declarations

Posted on 2003-11-21
9
419 Views
Last Modified: 2010-04-01
Is there a way of  using jsp custom tag in a jsp declaration such as:

<%!
public void pumpOutChildren(IItem currentItem)
{       
%>
<ms:bindings name="currentItem" id="boundItem">
<%=  
   boundItem.getFullName();
%>
</ms:bindings>
<%
}
%>

as this does not appear to work
0
Comment
Question by:danBosh
  • 4
  • 4
9 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 30 total points
ID: 9798965
I don't think so, as the <ms:bindings bit is outside the <%! bit, and therefore it is invalid in the generated servlet :-(

<%!
public void pumpOutChildren(IItem currentItem)
{      
%>

opens a new method in the generated Servlet, but it has no closing tags...so the JSP won't compile :-(

I hope you see what I mean...

Tim
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9798980
The answer to your question is NO!
because :
The tag needs other environment support that you don't have it in your declared method.
And you cannot mix <%! with <%.

Most of jsp processor will extract all <%! and process first, then the rest.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9799252
yeah...like I said... kinda ;-)
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 14

Expert Comment

by:kennethxu
ID: 9801201
sorry, only find that you have your message posted after I post mine.
points to TimYates
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9803271
> sorry, only find that you have your message posted after I post mine.

Hee hee...no worries :-)

I'm new to the JSP TA, and it's nice to see I was right :-)

Hehehe, now to catch you up ;-)

Tim
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9806302
Tim, I have seen that your answers were/are in high quality. I have limited time to support this TA and welcome all experts to contribute. :-)
0
 

Author Comment

by:danBosh
ID: 9809208
so there is no way of doing this, ignore my syntax, i just want to achieve something like that
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9809494
Hmmmm...

You can do:

<%!
public void pumpOutChildren( IItem currentItem )
{      
    out.println( currentItem.getFullName ) ;
}
%>

Not sure that "out" will be valid though...  you might need to do:

<%!
public void pumpOutChildren( IItem currentItem, PrintWriter out )
{      
    out.println( currentItem.getFullName ) ;
}
%>

Then you can call the method from your JSP code:

<%
  pumpOutChildren( item ) ;
%>

or

<%
  pumpOutChildren( item, out ) ;
%>
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9812643
>> i just want to achieve something like that
NO, not custom tag in a jsp declaration.

But you might be able to something similar with <jsp:include>
you put you custom tag in an included jsp page, and in the main page use <jsp:include> when you need to call it.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Stuck in Bootstrap WysiHtml Editor 3 42
Apache server configuration 7 87
Multiple Images Upload [JSP Web-application] 3 41
How can I   ajax html table  rows? 20 78
ConnectWise and their customers need to ensure critical alerts automatically reach the right person at the right time. MSP superheros efficiently respond to these alerts key is providing automatic, intelligent alerting that generates a complete audi…
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question