No tag "link" defined in tag library imported with prefix "h" | tomcat | eclipse - eclipse

I was working in Netbeans IDE and switched to Eclipse.
I created a simple JSF 2.0 based using wizard in eclipse. The complete file is this.
index.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%# taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%# taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<f:view>
<h1>Hi, This is my JSF 2. Applicaiton</h1>
<br />
Click <h:link outcome="UserLogin">here</h:link> to go to login
</f:view>
</body>
</html>
When I deploted this app in tomcat 7.0 server, I am getting the following error message,
org.apache.jasper.JasperException: /index.jsp(14,6) No tag "link" defined in tag library imported with prefix "h"
In my IDE also I can see the
Help appreciated.

The <h:link> was new in JSF 2.0 and didn't exist in JSF 1.x. This error can thus have the following causes:
You've actually JSF 1.x libraries in your /WEB-INF/lib, not JSF 2.0 libraries.
Your faces-config.xml is declared as JSF 1.x instead of JSF 2.0. Ensure that it is declared conform JSF 2.0 spec.
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">

A few quick questions:
Where is your JSF library located?
I think you meant more after:In my
IDE also I can see the which leads
into.
Eclipse is usually pretty good
at being able to find your tag
libraries. Is it complaining about
the use of these libraries in your
jsp editor page?
Let us know some more info about your setup first.
I'll throw out the obvious solution: You've lost the reference to your JSF jar(jsf-impl.jar). Including it in your Tomcat lib folder should fix it.

I'm in the middle of this problem too, I would like to find some solution, but I don't manage. As I found you are at the same step like me.
If you use facelets then you are able to see that tag, instead if you use normal "JSF" it gives the error as you mentioned.
You could try this procedure to solve your problem.
Try to understand how to configure facelets on your web app. For example for my webapp files that ends with *.xhtml are processed by facelets engine.
Rename file to *.xhtml.
Prepend this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
and
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
instead of normal html.
Remove any of the directive
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
Detailed instructions can be found here: http://wiki.apache.org/myfaces/MigrateFromJspToFacelets
Then you should be able to process h:link.

Related

"javax.servlet.jsp.tagext.SimpleTagSupport" was not found on the Java Build Path slice_new.tag

On JBoss server I have a slice_new.tag file
<%# attribute name="action" %>
<%# attribute name="icon" %>
<%# attribute name="pageId" %>
<%# attribute name="cost" %>
<%# attribute name="co2" %>
<%# attribute name="unit" %>
<%# tag language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
<title>${action}</title>
</head>
<body> ...
But I get this compilation error
The superclass "javax.servlet.jsp.tagext.SimpleTagSupport" was not found on the Java Build Path slice_new.tag
Please help me to fix it?
I recently solved this using the instructions from this site. Assuming you are using Eclipse: Right click on your project, select “Properties” -> “Project Facets” -> “Runtimes” , select your runtime container. Done, rebuild and refresh your project. See the link for screenshots.
Alternatively, I found this other solution as well. The class in question is from jsp-api.jar, so I added it as a provided dependency to my build. In maven this looks like this. Note that a 'provided' scope means not to bundle it in the WAR as it is expected to be provided by the container (e.g. Tomcat)
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>

Eclipse cannot find tld inside jar file

I have a jar file that contains some tag-files.
My *.tag files are inside /META-INF/tags/ folder (jar)
I also have a mytags.tld inside /META-INF/ folder (jar)
After pack all war project (with mytags.jar inside WEB-INF/lib folder), it works fine in JBoss. But Eclipse still cannot recognize the tag, getting the error Can not find the tag library descriptor for "http://www.mycompany.com"
Is there a way to Eclipse recognize my tags?
follow the sources:
block.tag
<%#tag description="Item do block" pageEncoding="UTF-8"%>
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%#attribute name="id" required="true" %>
<%#attribute name="label" required="true" %>
<%#attribute name="description" required="false" %>
<%#attribute name="icon" required="false" %>
<div id="${id}" class="block">
<div class="block-box ${icon}">
<div class="label">
<span>${label}</span>
</div>
<div class="description">
${description}
<jsp:doBody></jsp:doBody>
</div>
</div>
</div>
mytags.tld
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
version="2.1">
<description>My Tags</description>
<display-name>MyTags</display-name>
<tlib-version>1.0</tlib-version>
<short-name>mytags</short-name>
<uri>http://www.mycompany.com</uri>
<tag-file>
<name>block</name>
<path>/META-INF/tags/block.tag</path>
</tag-file>
</taglib>
some.jsp
<%#page contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8" %>
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%#taglib uri="http://www.mycompany.com" prefix="mytags" %> <-- ECLIPSE MARKS ERROR HERE
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<mytags:block id="users" label="Users" icon="user">
<!-- some content -->
</mytags:block>
</body>
</html>
But everything works fine in JBoss. Only eclipse accuses error.
Thanks
An existing bug report https://bugs.eclipse.org/bugs/show_bug.cgi?id=330405 suggests correcting the error message to point to the JSP version 1.1 detected from web.xml as a reason for the outdated interpretation of the taglib URI.
This is confirmed by a JSP Tag Libraries document, http://docs.oracle.com/cd/B14099_19/web.1012/b14014/taglibs.htm#i1014427:
As first defined in the JSP 1.1 specification, the taglib directive of a JSP page can fully specify the name and physical location, within a WAR file structure, of the TLD file that defines a particular tag library, as in the following example:
<%# taglib uri="/WEB-INF/oracustomtags/tlds/mytld.tld" prefix="oracust" %>
[..] Alternatively, as also defined since the JSP 1.1 specification, the taglib directive can specify the name and application-relative physical location of a JAR file instead of a TLD file
Both of the above 2 conventions retired to a fallback mechanism since JSP 1.2 which introduced mapping tag definitions and uses through the arbitrary taglib uri strings, http://docs.oracle.com/cd/B14099_19/web.1012/b14014/taglibs.htm#i1013109.
A recent JSP 2.1 spec documents the URI mapping in section JSP.7.3.2:
The URI describing a tag library is mapped to a TLD resource path though a
taglib map, and a fallback interpretation that is to be used if the map does not
contain the URI. The taglib map is built from an explicit taglib map in web.xml
(described in Section JSP.7.3.3) that is extended with implicit entries deduced
from packaged tag libraries in the web application (described in
Section JSP.7.3.4), and implicit entries known to the JSP container. The fallback
interpretation is targetted to a casual use of the mechanism, as in the development
cycle of theWeb Application; in that case the URI is interpreted as a direct path to
the TLD (see Section JSP.7.3.6.2).

JSP strange error in eclipse

I am a newbie in JSP and this is my first JSP.
<%#page import="java.util.Date"%>
<%# page language="java" contentType="text/html; charset=US-ASCII"
pageEncoding="US-ASCII"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Hello</title>
</head>
<body>
<h2>Hi There!</h2>
<br/>
<h3>Date=<%= new Date() %>
</h3>
</body>
</html>
On the line where I am creating Date object, Eclipse is giving error as
Syntax error on token ")", delete this token
My Eclipse version is:
Eclipse Java EE IDE for Web Developers.
Version: Kepler Release
Build id: 20130614-0229
problem got solved when I added jsp-api.jar into build path of the project.

JSP:include is not rendering the included file

I just created a new IceFaces application and I'm trying to include a navigation bar in all of the pages. When I use the jsp:directive.include tag the file is included, but when I use jsp:include it does not seem to be loaded. In fact, when I check the HTML source code in my browser, it's like the included file was completely empty. I do not want to use jsp:directive.include because it will not automatically show any updates to the included file.
My environment: Eclipse 3.5, Tomcat 6, JSF 1.2, IceFaces 1.8.
Steps to reproduce the problem and pieces of code:
create a new Dynamic Web Project with the following options:
Target runtime: Apache tomcat v6.0
Dynamic web module version: 2.5
Configuration: ICEfaces project
create a new ICEFaces JSPX file -- the home file. Some code:
<jsp:directive.page contentType="text/html;charset=ISO-8859-1" />
<f:view >
<ice:outputDeclaration doctypeRoot="HTML"
doctypePublic="-//W3C//DTD HTML 4.01 Transitional//EN"
doctypeSystem="http://www.w3.org/TR/html4/loose.dtd" />
<html>
<head>
<title>test file</title>
<link rel="stylesheet" type="text/css"
href="./xmlhttp/css/rime/rime.css" />
</head>
<body>
<jsp:directive.include file="./vertical_navigation.jsp" /> <!-- working -->
<jsp:include page="./vertical_navigation.jsp" /> <!-- not working, no error though -->
</body>
</html>
</f:view>
create the file to be included, also as a new ICEFaces JSPX file. Simplified code:
<ice:form>
<ice:panelGrid columns="1" width="152">
<ice:graphicImage url="./img/image.jpg"></ice:graphicImage>
<ice:panelCollapsible expanded="true">
<f:facet name="header">
<ice:panelGroup>
<ice:outputText value="Customer"/>
</ice:panelGroup>
</f:facet>
<ice:panelGrid columns="1">
<ice:commandLink action="customer"><ice:outputText value="Customer name" /></ice:commandLink>
</ice:panelGrid>
</ice:panelCollapsible>
</ice:panelGrid>
</ice:form>
</body>
</html>
</f:view>
Some remarks:
I'm completely new to JSF, so forgive me for any obvious mistake.
In the home file (the first one) I'm not using both tags at the same time. I pasted both here just to show that I am trying both options.
I created both files as "ICEFaces JSPX file", but the second one was assigned the .jsp extension.
When I use the directive.include tag, the included file is loaded. But if I change it, it's not automatically republished.
To start, you have to separate and distinguish several technologies:
JSP is a Java based view technology which allows you to write HTML/CSS/JS in and use taglibs to call backend Java code and/or control the output flow.
JSPX is the same as JSP, but forces you to write code in XML format. JSP-specific tags are replaced by tags in XML format. JSPX is also called "JSP Document". Here is a basic tutorial which outlines the differences in tags.
JSF is a component based MVC framework which provides components in flavor of taglibs which outputs HTML/CSS/JS.
You cannot use <jsp:include> in a JSPX page. You have to transform the JSPX page into a JSP page. You need to rename the file .jspx to .jsp and replace JSPX specific tags by JSP tags. Here's a kickoff example for JSP with JSF/IceFaces:
<%# page pageEncoding="ISO-8859-1" %>
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%# taglib uri="http://www.icesoft.com/icefaces/component" prefix="ice"%>
<!DOCTYPE html>
<f:view>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<jsp:include page="include.jsp" />
</body>
</html>
</f:view>

Validation problem with JSP and Eclipse

I have this simple JSP page in Eclipse and the first line in the file is:
Eclipse however, puts a yellow warning icon before this line with the following tooltip message:
Multiple annotations found at this
line:
- Line breakpoint:index.jsp [line: 1]
- Tag (jsp:directive.page) should be an empty-element tag.
Does anyone know why this is?
UPDATE:
This is my full source script. This is basically the template that Eclipse generates for me when I create a new JSP file based on the XHTML template. I only slightly modified the content to make it do something 'use full'.
I'm using Eclipse 3.4 (eclipse-jee-ganymede-SR1-linux-gtk.tar.gz) on Ubuntu 8.10 with the Geronimo 2.1 plug-in (I don't think that matters though). I had this same problem with every version of Eclipse I've used so far (3.0 and up)
<%# page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<jsp:useBean id="datetime" class="java.util.Date" />
<html>
<head>
<title>Hello Geronimo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div>
<h1>Hello Apache Geronimo!!!</h1>on ${datetime}
</div>
</body>
</html>
It's an oddity of the DOM validation that happens in the editor even for JSP files, reported in bug 248963 for another situation.
It's expected to be resolved in WTP 3.0.4 & Ganymede SR2.
So what eclipse and WTP version are you using ?
Can you check if this is still the case when you add the following line just beneath the initial jsp declaration:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
as mentioned in bug 257258 (also fixed in WTP 3.0.4 & Ganymede SR2): before WTP3.0.4, this doctype was enough to not show your warning:
(source: eclipsetotale.com)