• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

problem with JSTL

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends....

I am trying to test JSTL but encountering some error with uri which we are mentioning in our jsp.
Here is the code

HTML file :

<html>
<body>

<h1 align="center">Movie Page </h1>
<form method="POST" action="JSTLSelect.do">
<select name="movie" size="1">
<option>type-1
<option>type-2
</select>
<br><br>
<center>
<input type="SUBMIT">
</center>
</form>\
</body>
</html>
=========================================================================

Servlet File: JSTLSelect
package com;

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;


/**
* @version 1.0
* @author
*/
public class JSTLSelect extends HttpServlet {


public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("JSLT Testing");
String[] movieList = {"mv-1", "mv-2", "mv-3", "mv-4" };
request.setAttribute("movieList",movieList);
RequestDispatcher view = request.getRequestDispatcher("JSTL_jsp.jsp");
view.forward(request,response);
}
}

===========================================================================

JSTL_jsp.jsp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<HTML>
<HEAD>
<%@ page
language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM WebSphere Studio">
<TITLE>JSLT_jsp.jsp</TITLE>
</HEAD>
<BODY>
<P>Place content here.</P>
<table>
<c:forEach var="movie" items="${movieList}">
<tr>
<td> ${movie}</td>
</tr>
</c:forEach>
</table>
</BODY>
</HTML>
========================================================================

My web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app 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-app_2_4.xsd" id="WebApp" version="2.4">
<display-name>ELTest</display-name>

<servlet>
<servlet-name>JSTLSelect</servlet-name>
<display-name>JSTLSelect</display-name>
<servlet-class>com.JSTLSelect</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>JSTLSelect</servlet-name>
<url-pattern>/JSTLSelect.do</url-pattern>
</servlet-mapping>



<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>





========================================================================

Error which I am getting is as follows :


HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:365)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:151)
at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:351)
at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:171)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:453)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:514)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1562)
at org.apache.jasper.compiler.Parser.parse(Parser.java:171)......................................................................................................................................
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
just check with the taglib element in the web.xml..
the error given is that no absolute path found in web.xml or in any jar file...so just give a try specifiying
<taglib>
<taglib-uri>coretags</taglib-uri>
<taglib-location>http:\\..ur abosolute uri here</taglib-location?
</taglib>
in web.xml...and in the jsp page..where you import <%@ taglib uri="coretags" ....%>
so here it checks coretags with the absolute uri you have given in the taglib-location.....
this procedure we generally do for custom tags..but for jstl..once we include the neccessary files..there is no need for this procedure....as the container does automatically ..looks for its required files ....so just give a try..if it works.....hope i am clear..

regards
vandu
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vandu, no offense, but I'm not sure you know what you are talking about

Puja,
it seems that your container does not find the uri to the jstl taglib.
Make sure that standard.jar and jstl.jar are in your lib directory.

I think you'll find the following FAQ useful :
http://faq.javaranch.com/view?JstlTagLibDefinitions
 
Puja Verma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the output

The problem was the absence of JAR files. I have added them and my program is working fine.. .
Thanks for your help..
 
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic