File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL/core with Tomcat 7 is giving HTTP Status 404 error

 
vani patel
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i new to JSTL and am tring one example code is given below demo2.jsp and my server is Tomcat 7 ,your any help would be appriciated, i added below jar files in build path
core-3.1.1.jar
jsp.2.1.jar
jsp-api.jar
jsp-api-2.1.jar
jstl-1.2.jar
servlet-api.jar

and when i run this jsp file i am getting below error, i tried other files without jstl it is working fine

demo2.jsp

`<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<html>
<body>
<form method=post action="demo2.jsp">
<jsp:useBean id="bean1" class="ourbeans.player">
<jsp:setProperty name="bean1" property="*" />
</jsp:useBean>
Name <input type=text name="name"><br>
Place<input type=text name="place"><br>
Game<input type=text name="game"><br>
<input type=submit>
</form>

Name: <c:out value="${bean1.name}" /><br>
Place: <c:out value="${bean1.place}" /><br>
Game: <c:out value="${bean1.game}" />
</body>
</html>
`
// player.java `package ourbeans;




public class player{
String name;
String place;
String game;
public player(){
name=" ";
place=" ";
game=" ";
}
//---------------------------

public void setName(String a){
name=a;
}

public void setPlace(String b){
place=b;
}

public void setGame(String c){
game=c;
}
//------------------------------

public String getName(){
return name;
}

public String getPlace(){
return place;
}

public String getGame(){
return game;
}

}
`
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you put the jstl-1.2.jar in WEB-INF/lib?

(Note: do not copy any of the other jars to WEB-INF/lib, only the JSTL jar)
 
vani patel
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes i did put below jars in WEB-INF/lib folder and then added in build path
core-3.1.1.jar
jsp.2.1.jar
jsp-api.jar
jsp-api-2.1.jar
jstl-1.2.jar
servlet-api.jar

Shall i remove all other jar files from lib and from build path except jstl-1.2.jar?

btw thanks for answering
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No one said anything about the build path. All the jars need to be on the build path.

WEB-INF/lib has nothing to do with the build path. It's what is used at run time. The build path is meaningless at run time.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vani patel wrote:Yes i did put below jars in WEB-INF/lib folder

Remove them. All but the JSTL jar.

Putting those other ars in WEB-INF/lib will cause no end of class loader problems. Tomcat supplies those files at run-time.
 
vani patel
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried removing all other jars except jstl-1.2.jar in WEB-INF/lib and even from the build path but i am gettign still same error
HTTP Status 404 - /1/

--------------------------------------------------------------------------------

type Status report

message /1/

description The requested resource is not available.


--------------------------------------------------------------------------------

Apache Tomcat/7.0.35

Can you please help me if possible as i am stuck at the first stage to learn JSTL
 
Stefan Evans
Bartender
Posts: 1640
9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest to start simply.

#1: Get a "Hello world" JSP page to display with just static text, and nothing else. Here is one of the basic diagnostic pages I use regularly:



#2: Add an EL expression to the page to ensure that works

should produce "2 + 2 = 4"

#3: Add JSTL library and a JSTL tag




NOTE: you have been using the OLD uri for JSTL. Make sure you use the new one like in the example here.
(Note the subtle addition of the "/jsp" in the middle of it)

 
Sagar Vyas
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vani patel wrote:Hi i new to JSTL and am tring one example code is given below demo2.jsp and my server is Tomcat 7 ,your any help would be appriciated, i added below jar files in build path
core-3.1.1.jar
jsp.2.1.jar
jsp-api.jar
jsp-api-2.1.jar
jstl-1.2.jar
servlet-api.jar

and when i run this jsp file i am getting below error, i tried other files without jstl it is working fine

demo2.jsp

`<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>



Hi Vani,

Can you please try with following ?

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

HTH.

Thanks,
Sagar Vyas
 
vani patel
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stefan and Sagar for your help.

I could solve the problem by doing fresh start and updating URI with adding JSP, actually i did tried with new URL too but that time it did not worked,

But now with only one JSTL jar and new URI it is working fine, this was my first question and could solve problem so thanks for now and future for more questions.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic