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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • 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
here is File.jsp:
<jsp:useBean id="cool" class="mytagdir.MyBean" scope="session" />
<% out.write(cool.getMarks()); %>
<% out.print(cool.getMarks()); %>
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?
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 when you call out.write(int i) it uses 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!
    Bookmark Topic Watch Topic
  • New Topic