Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

Custom Tags including other tags

Thread view: 
joseph.berthe@gmail.com - 15 Jan 2006 22:55 GMT
Hi,

I want to create a Custom Tags which display a login page.

I have created a file with all graphical stuffs. Inside that file I
want to put on some JSP functions such as using variables or other
tags.

Furthermore I want to create a custom tags which able to include that
graphical file.

My problem is my graphical file is included like only text, so all JSP
stuff are not used.

I have already tested :
  -- pageContext.include(myFile.jsp);
  -- pageContext.include(myFile.jsp, true);

 In doAfterBody
  -- BodyContent body = getBodyContent();
     JspWriter wout = body.getEnclosingWriter();
     wout.println("<%@ include file=\"formlogin.jsp\" ");
     body.clearBody();

Obviouly the problem comes from the compilation schedule. I mean when I
want to write down JSP stuff inside my page, it is to late, the
compiler has already compile the files and it think it is just text.

Thanks
Raymond DeCampo - 16 Jan 2006 01:55 GMT
> Hi,
>
[quoted text clipped - 23 lines]
> want to write down JSP stuff inside my page, it is to late, the
> compiler has already compile the files and it think it is just text.

Try using the include() method on the javax.servlet.RequestDispatcher class.

HTH,
Ray

Signature

This signature intentionally left blank.

John C. Bollinger - 16 Jan 2006 03:57 GMT
> Try using the include() method on the javax.servlet.RequestDispatcher
> class.

Or equivalently, the <jsp:include/> standard action.

Signature

John Bollinger
jobollin@indiana.edu

joseph.berthe@gmail.com - 19 Jan 2006 13:03 GMT
Thanks,

So it doesn't work at all. The only positive thing is now I can insert
HTML files.

Remark :
But i'm thinking about that technology (Custom Tags). My goal is to put
graghical component inside a tags and interact with it and reuse it.
But probably it is not suitable for that. I have read something about
STRUTS, probably this is what I need. What do you think ?

I have done :

---------------------------JAVA file -----------------------
public class loginform extends BodyTagSupport {

    //Variables
   ....

 // Functions
  ....

   public int doStartTag() throws JspException{
       try {
       } catch (Exception e) {
           throw new Error("That's bad.start");
       }
       return EVAL_BODY_BUFFERED;
   }

   public int doAfterBody() throws JspException{
       try {
           String resource = "formlogin.jsp";
           ServletRequest req = pageContext.getRequest();
           ServletResponse res = pageContext.getResponse();
           RequestDispatcher rd = req.getRequestDispatcher(resource);
           rd.include(req, res);

       } catch(Exception e ) {
           throw new Error("That's bad body." + e);
       }
       return EVAL_BODY_BUFFERED;
   }

   public int doEndTag() throws JspException{
       try {

       } catch (Exception e) {
           throw new Error("That's bad.end");
       }
       return SKIP_PAGE;
   }
}

-------------- TLD File ----------------------
<taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
web-jsptaglibrary_2_0.xsd">
 <tlib-version>1.0</tlib-version>
 <short-name>loginform</short-name>
 <uri>/WEB-INF/tlds/loginform</uri>

 <tag>
   <name>loginform</name>
   <tag-class>MyTags.loginform</tag-class>
   <body-content>tagdependent</body-content>
 </tag>
</taglib>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.