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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -