java - How to access to element from another class -
i have servlet need show list of products first image next title , price.
i try with
proizvodi pr = new proizvodi(); for(int i=0; i<pr.getkatalog().size();i++) { out.println("<br />"); out.print("<img src='pr.getkatalog().get(i).getimg()'>"); out.print("<p>pr.getkatalog().get(i).gettitle()</p> "); out.print("<p>pr.getkatalog().get(i).getprice()</p> "); }
but doesn't work. hope u can me.
you need replace this:
out.print("<img src='pr.getkatalog().get(i).getimg()'>");
with
out.print("<img src='" + pr.getkatalog().get(i).getimg() + "'>");
to method return value appended string. otherwise pr.getkatalog().get(i).getimg()
being in double quotes treated normal string , not method call.
you need same thing these statements well:
out.print("<p>pr.getkatalog().get(i).gettitle()</p> "); out.print("<p>pr.getkatalog().get(i).getprice()</p> ");
Comments
Post a Comment