aspose file tools*
The moose likes JSP and the fly likes How to run simple JSTL page? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to run simple JSTL page?" Watch "How to run simple JSTL page?" New topic
Author

How to run simple JSTL page?

Arpit Gadle
Ranch Hand

Joined: Dec 16, 2008
Posts: 69

Hello All,
I am having a JSTL test page as below

easy.jsp


At the first run I got an exception for URI Path. So I added jstl.jar and standard.jar file in the lib dir of this web-app. And here is the result

Output

JSP is as easy as....
1+2+3=${1+2+3}

But the output should be

JSP is as easy as....
1+2+3=6

Have I missed something inspite of adding the above said jar files. Do I have to add the tld and where.


Regards,
Arpit
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

Arpit Gadle wrote:At the first run I got an exception for URI Path. So I added jstl.jar and standard.jar file in the lib dir of this web-app. And here is the result
Output
JSP is as easy as....
1+2+3=${1+2+3}

But the output should be

JSP is as easy as....
1+2+3=6
Have I missed something inspite of adding the above said jar files. Do I have to add the tld and where.

Looks like you have EL disabled for your JSP. What is the container you are using ? Are you have anything to do with EL in the web.xml in the application ?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Arpit Gadle
Ranch Hand

Joined: Dec 16, 2008
Posts: 69

I am using Apache Tomcat 6 and there is nothing in web.xml related to EL.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

Arpit Gadle wrote:I am using Apache Tomcat 6 and there is nothing in web.xml related to EL.

What is the version of your web.xml (inside <web-app>) ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42281
    
  64
This should help: http://faq.javaranch.com/java/ElOrJstlNotWorkingAsExpected


Ping & DNS - my free Android networking tools app
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

Hi Ulf, There's a small typo ( "Servlers 2.3 DOCTYPE" ) in it.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42281
    
  64
There's a small typo ( "Servlers 2.3 DOCTYPE" ) in it.

It's a wiki - go ahead and fix it :-) Username/password are the same as for the Saloon.
Arpit Gadle
Ranch Hand

Joined: Dec 16, 2008
Posts: 69

Hello Everyone,
I am using Tomcat 6.0(Servlet 2.5 and JSP 2.1) and JSTl 1.2

Here is the source code and the webx.xml

easy.jsp


web.xml



And edited the web.xml as mentioned in "El Or Jstl Not Working As Expected"

Then also i am getting the same outut as

JSP is as easy as....
1+2+3=${1+2+3}

bye
Arpit

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

Place the EL expression outside of the <c:out> tag to make sure that the EL is working properly. If not, then that's the issue that must be addressed before worrying about the JSTL.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Arpit Gadle
Ranch Hand

Joined: Dec 16, 2008
Posts: 69

Thanks Bibeault,
Now Its working. Could you suggest me any book for JSTL.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

You don't need a book, just the JSTL Specification.

So you say that the EL works outside of the <c:out> tag? If so, your web app is correctly configured.

OK, now put the <c:out> tag back in and see what's being sent to the browser with a View Source. If the <c:out> tag is still there, that means that the JSTL is not being evaluated.
Arpit Gadle
Ranch Hand

Joined: Dec 16, 2008
Posts: 69

Here is the latest update.

As I am using Tomcat 6(Servlet 2.5 and JSP 2.1) and I had revert back all the changes

easy.jsp


web.xml


And added this directive as mentioned by Avi Sinha in some other post



Now everything is working fine

Thanks for your reply.


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

So you'd rather use a band-aid and some bubble gum to hold your web app together than to get it working and configured correctly?
Arpit Gadle
Ranch Hand

Joined: Dec 16, 2008
Posts: 69

Thanks Bibeault,
I understood what you want to say. From now onwards, I will configure my all web-apps correctly instead of trying bubble gum and band-aids to make things working. Is correct configuration for web-app available in JSTL 1.2 Specification? Where I can find it?

Thanks once again for your adivce,

Arpit
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

There's no configuration. Once the EL is working -- you said it was working, correct? -- using the EL is as easy as dropping the jar file into WEB-INF/lib.

That's it.

You haven't answered the questions that I posed earlier yet...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42281
    
  64
Is correct configuration for web-app available in JSTL 1.2 Specification? Where I can find it?

Perhaps you missed my first post?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to run simple JSTL page?