• Post Reply Bookmark Topic Watch Topic
  • New Topic

tag libs with weblogic6.1  RSS feed

 
padmini rao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,
I am new to jsp and just been trying to work with tag libs on weblogic6.1 . I am working with an example from professional jsp (wrox publications) book . Tag lib only prints "hello world" . The following is the jsp
<%@ taglib uri="hello.tld" prefix="examples" %>
<html>
<head>
<title>First custom tag</title>
</head>
<body>
this is static output
<p/>
<i>
<examples:hello></examples:hello>
</i>
this is static output
</body>
</html>
When i execute this example
this is static output
this is static output
is displayed on the browser .
hello world is not displayed . Can anyone please tell me why this is happening .
The same ex has worked fine in tomcat 3.2.1
Thanks
Padmini
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you set up the taglib uri-location mapping in the web.xml file?
Simon
 
padmini rao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Simon ,
YEs I have set up the taglib uri-location mapping in the web.xml file . I have placed the .tld file in WEB-INF directory and have mapped it as
<taglib-location>WEB-INF/hello.tld</taglib-location>
in the web.xml
Thanks
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check the source code of the HTML, is the hello:world or whatever tag still in the HTML? This is an issue that I've had when I started off, where the tag wasnt being processed and therefore the output still contained the tag in it. As the browser doesnt recognize the tag, it just ignores it and nothing happens.
otherwise, if the hello world tag is being processesd but isnt outputting anything, post your code so that we can check it. It may be that the output isnt being properly flushed to the reponse output stream si it just gets lost
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"padmini",
Thanks for participating here at the Ranch. However, the name you are using does not comply with the naming convention described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name (not fictitious monikers). Please log in with a new name which meets the requirements.
Thanks.
Sean
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Simon Brown:
Have you set up the taglib uri-location mapping in the web.xml file?
Simon

Hi Padmini, thanks for the private message on this, having looked at the way you've set everything up on the war file, I am pretty sure that the problem is the one simon asked about. You've forgotten to link the tld file in web.xml. I can tell you for sure if you send the resultant html
 
padmini rao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I have linked the tld in the web.xml . here is a part of the web.xml where i have linked the tld
<?xml version="1.0" ?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>First</servlet-name>
<servlet-class>First</servlet-class>

</servlet>
....
.....
....
.....
.....
<taglib>
<taglib-uri>hello</taglib-uri>
<taglib-location>WEB_INF/hello.tld</taglib-location>
</taglib>
</web-app>
since it is packaged into a war file hello.war, the url given in the browser is http://localhost:7001/hello/hello.jsp .
The result html is
this is static output
this is static output
Thanks
Padmini
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we see the source of the resultant html - it should look like this:
<html>
<head>
<p>This is static text
etc
not just what you see in the browser but what you see if you right click and choose source. I want to check if the tag is being processed or not.
 
Jignesh Malavia
Author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Padmini!
Two important points:
1st: Since you have used hello (and not hello.tld) for taglib-uri in web.xml, use hello instead of hello.tld in the taglib directive too as <@taglib uri="hello" prefix="test" >
2nd: For the taglib-location in web.xml, use a forward slash before the WEB-INF/hello.tld. Otherwise the JSP engine will assume the location as /WEB-INF/WEB-INF/hello.tld.
Btw, isn't the engine complaining about not finding the TLD? May be because it is finding the TLD in the same directory as the JSP page. (Since you have used "hello.tld" in the directive)
-j
 
padmini rao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
This is the source of the resultant html
<%@ taglib uri=hello prefix="examples" %>
<html>
<head>
<title>First custom tag</title>
</head>
<body>
this is static output
<p/>

<examples:hello></examples:hello>

this is static output
</body>
</html>
[ July 07, 2002: Message edited by: padmini rao ]
 
padmini rao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jignesh ,
In the taglib directive , if the uri is given without quotes like
<%@ taglib uri=hello directive="examples %> . I get the result as mentioned above but if the uri is given with quotes
<%@ taglib uri="hello" prefix="examples" %> , the engine complains of not finding the handler class and there is an error message in the browser also as follows
Parsing of JSP File '/hello.jsp' failed:
--------------------------------------------------------------------------------
/hello.jsp(1): Error in using tag library uri='hello' prefix='examples': cannot find tag class: 'tagext/HelloTag'
probably occurred due to an error in /hello.jsp line 1:
<%@ taglib uri="hello" prefix="examples" %>
Thanks
Padmini
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think you are not too far away from dealing with this now. The quotes btw are absolutely required by the XML spec so the problem is not that you put them in. Basically the jsp servlet that compiles you jsp cant find Hello.class.
How familiar are you with compilinig a class into a package? The JSP servlet is expecting to find you Hello.class file in a folder called tagext in the classpath and that the file would have been compiled with a
package tagext; statement and so on.
If you havent done much in the way of packages then you might consider changing the fiel so that Hello isnt in a package and just putting Hello.class in the classes/ directory and removing the package statement at the top of the class file. You would then need to change your tld file not to quote the handler as tegext.Hello but just Hello. If you havent put the package line at the top of the java file then your tld file just needs fixing.
 
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!