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 ..c:set

 
Neeraj Vij
Ranch Hand
Posts: 315
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to jstl..pls. help..



Can I set the value of a string variable in <c:set ?

if yes. give any example.

Regards,
Neeraj.
 
Raghu Shree
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Using <c:set> we can store values and object and also in different scope.
some examples,
<c:set var="place" value="Chennai"/>
<c:set var="name1" value="value1" scope="page" />
<c:set var="com_mycompany_name2" value="value2" scope="request" />
<c:set var="com_mycompany_name3" value="value3" scope="session" />
<c:set var="com_mycompany_name4" value="value4" scope="application" />
[ October 19, 2005: Message edited by: Raghu Shree ]
 
Neeraj Vij
Ranch Hand
Posts: 315
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

thnx for the inputs.. but I want something like this..

<%
String strCity="xyz";
%>

and assign this variable in value like

<c:set var="home" value="<%= strCity %>" scope="session"/>

but this is not working...need some other way of doing it..

Regards,
Neeraj.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

thnx for the inputs.. but I want something like this..

<%
String strCity="xyz";
%>

and assign this variable in value like

<c:set var="home" value="<%= strCity %>" scope="session"/>

but this is not working...need some other way of doing it..

Regards,
Neeraj.
 
Raghu Shree
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Try like this
<%
String strCity="XYZ";
pageContext.setAttribute( "city", strCity);
%>

then

<c:set var="home" value="<%= strCity %>" scope="session"/>

(or)

<c:set var="home" value="${strCity}" scope="session"/>

Hope this will helps you.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thnx again..

I have trying out this sample

<%
String name="neeraj";
pageContext.setAttribute("name1",name);
%>
name1:<c ut value="${name1}" />
<br>


<c:choose>
<c:when test ="${name1 eq 'neeraj'}">
HELLO &&&&

</c:when>
</c:choose>

I am getting this error.. I am unable to debug it..
org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
Syntax error, insert "Finally" to complete TryStatement

Generated servlet error:
Syntax error on token "catch", Identifier expected

Generated servlet error:
out cannot be resolved

Generated servlet error:
_jspx_out cannot be resolved

Generated servlet error:
out cannot be resolved

Generated servlet error:
out cannot be resolved

Generated servlet error:
out cannot be resolved

Generated servlet error:
_jspx_page_context cannot be resolved

Generated servlet error:
_jspx_page_context cannot be resolved

Generated servlet error:
Syntax error on token "finally", { expected

Generated servlet error:
_jspxFactory cannot be resolved

Generated servlet error:
_jspxFactory cannot be resolved

Generated servlet error:
_jspx_page_context cannot be resolved
 
Raghu Shree
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
To sort out the propbelm remove all jstl tags except the follwing.
<%
String name="neeraj";
pageContext.setAttribute("name1",name);
%>
name1:<c ut value="${name1}" />
<br>

If the error agin occurs give me your whole jsp file.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic