print attribute of object with jsp expression in jsp file
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
i send the object to jsp with set.Atrribute and i want to print this object in h5 tag with jsp exprissoin but i can't. my cod is:
<%
List<News>news = (List<News>) request.getAttribute("news");
for(int i=0;i<news.size();i++)
News n = news.get(i);
%>
<div class="card text-white bg-info mb-3" style="max-width: 18rem;">
<div class="card-header">gggggggggggggggggg</div>
<div class="card-body">
<h5 class="card-title"> <% n.title %> </h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
<%
%>
java jsp
add a comment |
i send the object to jsp with set.Atrribute and i want to print this object in h5 tag with jsp exprissoin but i can't. my cod is:
<%
List<News>news = (List<News>) request.getAttribute("news");
for(int i=0;i<news.size();i++)
News n = news.get(i);
%>
<div class="card text-white bg-info mb-3" style="max-width: 18rem;">
<div class="card-header">gggggggggggggggggg</div>
<div class="card-body">
<h5 class="card-title"> <% n.title %> </h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
<%
%>
java jsp
Please clarify what you mean by "can't".
– SamTebbs33
Nov 16 '18 at 11:47
add a comment |
i send the object to jsp with set.Atrribute and i want to print this object in h5 tag with jsp exprissoin but i can't. my cod is:
<%
List<News>news = (List<News>) request.getAttribute("news");
for(int i=0;i<news.size();i++)
News n = news.get(i);
%>
<div class="card text-white bg-info mb-3" style="max-width: 18rem;">
<div class="card-header">gggggggggggggggggg</div>
<div class="card-body">
<h5 class="card-title"> <% n.title %> </h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
<%
%>
java jsp
i send the object to jsp with set.Atrribute and i want to print this object in h5 tag with jsp exprissoin but i can't. my cod is:
<%
List<News>news = (List<News>) request.getAttribute("news");
for(int i=0;i<news.size();i++)
News n = news.get(i);
%>
<div class="card text-white bg-info mb-3" style="max-width: 18rem;">
<div class="card-header">gggggggggggggggggg</div>
<div class="card-body">
<h5 class="card-title"> <% n.title %> </h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
<%
%>
java jsp
java jsp
asked Nov 16 '18 at 11:42
Mohammad HooshmandMohammad Hooshmand
32
32
Please clarify what you mean by "can't".
– SamTebbs33
Nov 16 '18 at 11:47
add a comment |
Please clarify what you mean by "can't".
– SamTebbs33
Nov 16 '18 at 11:47
Please clarify what you mean by "can't".
– SamTebbs33
Nov 16 '18 at 11:47
Please clarify what you mean by "can't".
– SamTebbs33
Nov 16 '18 at 11:47
add a comment |
1 Answer
1
active
oldest
votes
if the title member of News then it should work as is
if you use encapsulation and you expose the title field the you have to call the get method which is public.
<h5 class="card-title"> <% n.getTitle(); %> </h5>
if it does not work try this and make sure you follow this tutorial:
<c:forEach items="$(List<News>) request.getAttribute("news")" var="news">
<div class="card text-white bg-info mb-3" style="max-width: 18rem;">
<div class="card-header">gggggggggggggggggg</div>
<div class="card-body">
<h5 class="card-title">$news.title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</c:forEach>
also, in order for the c tag to work you have to declare the tag library:
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
title is public in definition but n.title don't work
– Mohammad Hooshmand
Nov 16 '18 at 11:56
when i use n.title in first part of expression on below for statement is work but in h5 tag is not work
– Mohammad Hooshmand
Nov 16 '18 at 12:00
I edited my answer
– aurelius
Nov 16 '18 at 12:18
thanks it's work
– Mohammad Hooshmand
Nov 16 '18 at 12:22
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337188%2fprint-attribute-of-object-with-jsp-expression-in-jsp-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
if the title member of News then it should work as is
if you use encapsulation and you expose the title field the you have to call the get method which is public.
<h5 class="card-title"> <% n.getTitle(); %> </h5>
if it does not work try this and make sure you follow this tutorial:
<c:forEach items="$(List<News>) request.getAttribute("news")" var="news">
<div class="card text-white bg-info mb-3" style="max-width: 18rem;">
<div class="card-header">gggggggggggggggggg</div>
<div class="card-body">
<h5 class="card-title">$news.title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</c:forEach>
also, in order for the c tag to work you have to declare the tag library:
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
title is public in definition but n.title don't work
– Mohammad Hooshmand
Nov 16 '18 at 11:56
when i use n.title in first part of expression on below for statement is work but in h5 tag is not work
– Mohammad Hooshmand
Nov 16 '18 at 12:00
I edited my answer
– aurelius
Nov 16 '18 at 12:18
thanks it's work
– Mohammad Hooshmand
Nov 16 '18 at 12:22
add a comment |
if the title member of News then it should work as is
if you use encapsulation and you expose the title field the you have to call the get method which is public.
<h5 class="card-title"> <% n.getTitle(); %> </h5>
if it does not work try this and make sure you follow this tutorial:
<c:forEach items="$(List<News>) request.getAttribute("news")" var="news">
<div class="card text-white bg-info mb-3" style="max-width: 18rem;">
<div class="card-header">gggggggggggggggggg</div>
<div class="card-body">
<h5 class="card-title">$news.title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</c:forEach>
also, in order for the c tag to work you have to declare the tag library:
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
title is public in definition but n.title don't work
– Mohammad Hooshmand
Nov 16 '18 at 11:56
when i use n.title in first part of expression on below for statement is work but in h5 tag is not work
– Mohammad Hooshmand
Nov 16 '18 at 12:00
I edited my answer
– aurelius
Nov 16 '18 at 12:18
thanks it's work
– Mohammad Hooshmand
Nov 16 '18 at 12:22
add a comment |
if the title member of News then it should work as is
if you use encapsulation and you expose the title field the you have to call the get method which is public.
<h5 class="card-title"> <% n.getTitle(); %> </h5>
if it does not work try this and make sure you follow this tutorial:
<c:forEach items="$(List<News>) request.getAttribute("news")" var="news">
<div class="card text-white bg-info mb-3" style="max-width: 18rem;">
<div class="card-header">gggggggggggggggggg</div>
<div class="card-body">
<h5 class="card-title">$news.title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</c:forEach>
also, in order for the c tag to work you have to declare the tag library:
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
if the title member of News then it should work as is
if you use encapsulation and you expose the title field the you have to call the get method which is public.
<h5 class="card-title"> <% n.getTitle(); %> </h5>
if it does not work try this and make sure you follow this tutorial:
<c:forEach items="$(List<News>) request.getAttribute("news")" var="news">
<div class="card text-white bg-info mb-3" style="max-width: 18rem;">
<div class="card-header">gggggggggggggggggg</div>
<div class="card-body">
<h5 class="card-title">$news.title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</c:forEach>
also, in order for the c tag to work you have to declare the tag library:
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
edited Nov 16 '18 at 12:06
answered Nov 16 '18 at 11:48
aureliusaurelius
2,11121953
2,11121953
title is public in definition but n.title don't work
– Mohammad Hooshmand
Nov 16 '18 at 11:56
when i use n.title in first part of expression on below for statement is work but in h5 tag is not work
– Mohammad Hooshmand
Nov 16 '18 at 12:00
I edited my answer
– aurelius
Nov 16 '18 at 12:18
thanks it's work
– Mohammad Hooshmand
Nov 16 '18 at 12:22
add a comment |
title is public in definition but n.title don't work
– Mohammad Hooshmand
Nov 16 '18 at 11:56
when i use n.title in first part of expression on below for statement is work but in h5 tag is not work
– Mohammad Hooshmand
Nov 16 '18 at 12:00
I edited my answer
– aurelius
Nov 16 '18 at 12:18
thanks it's work
– Mohammad Hooshmand
Nov 16 '18 at 12:22
title is public in definition but n.title don't work
– Mohammad Hooshmand
Nov 16 '18 at 11:56
title is public in definition but n.title don't work
– Mohammad Hooshmand
Nov 16 '18 at 11:56
when i use n.title in first part of expression on below for statement is work but in h5 tag is not work
– Mohammad Hooshmand
Nov 16 '18 at 12:00
when i use n.title in first part of expression on below for statement is work but in h5 tag is not work
– Mohammad Hooshmand
Nov 16 '18 at 12:00
I edited my answer
– aurelius
Nov 16 '18 at 12:18
I edited my answer
– aurelius
Nov 16 '18 at 12:18
thanks it's work
– Mohammad Hooshmand
Nov 16 '18 at 12:22
thanks it's work
– Mohammad Hooshmand
Nov 16 '18 at 12:22
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337188%2fprint-attribute-of-object-with-jsp-expression-in-jsp-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please clarify what you mean by "can't".
– SamTebbs33
Nov 16 '18 at 11:47