Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

write() v/s println()

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Paper beats rock. Scissors beats tiny ad.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic