• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

write() v/s println()

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi!
here is File.jsp:
<jsp:useBean id="cool" class="mytagdir.MyBean" scope="session" />
<% out.write(cool.getMarks()); %>
<% out.print(cool.getMarks()); %>
MyBean.java:
package mytagdir;
public class MyBean {
public MyBean() {
System.out.println("constructor of MyBean");
}
public int getMarks() {
return 100;
}
}
When we access the File.jsp file through the browser then it shows "d 100". I didn't get why the write method in jsp file returns the ascii value of the output of getMarks() method?
ashok.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in your JSP page, "out" is instance of class JspWrite which entends from java.io.Writer. when you call out.write(int i) it uses java.io.Writer method:
write(int c)
Write a single character.
when you call out.print(int i) it uses JspWriter method:
print(int i)
Print an integer.
that is the reason you got the output of "d 100".
wish that will help.
Big Cat
 
Do not set lab on fire. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic