• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

classes

 
Relu Ovidiu
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a class...and i want, in one of the class's method, to print a text on the screen..but a recive an error( i'm using out.println)...how can i do that?Thnx!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch James.
but a recive an error( i'm using out.println)...how can i do that?

You can begin by giving us more information. What is the line of code that is causing the error, and what is the exact wording and nature of the error.
Otherwise, it's just guesswork.
[ March 18, 2004: Message edited by: Bear Bibeault ]
 
Relu Ovidiu
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i print a text on the screen(web page) using a class's method? (it doesnt't mater what class .. and what method...) Can u give me an example with a class and a method that print a text? (jsp/servlet) ....Thnx!
 
eammon bannon
Ranch Hand
Posts: 140
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your code. Post your error. Then maybe someone might be able to spot what's wrong.
 
Gowrishankar Mudaliar
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try passing the response object to the class and then do response.getWriter().
This should give you a printwriter reference. You can use this to write to the web page.
To be more precise, you have to post your code.
 
Winston Smith
Ranch Hand
Posts: 136
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can call a method such as this from your JSP:

On your JSP page, you would have something like:
 
Raghav Mathur
Ranch Hand
Posts: 641
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure whether i've understood ur question correctly but leme try .
1) make a class wth a function . e.g:
public class test
{
public String getStr()
{
String str = new String();
str = "JAMES";
return str;
}
}
2) call this class in the jsp and using the class object, call this function. E.g :
Test t = new Test();
String str = t.getStr();
out.println(str);
3) run the jsp file and see the output . If it doesn't print "JAMES" then there is something wrong in your calling the class file.
Hope this helps
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic