• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

classes

 
Greenhorn
Posts: 12
  • 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!
 
Sheriff
Posts: 67268
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
  • 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!
 
Ranch Hand
Posts: 140
  • 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.
 
Ranch Hand
Posts: 39
  • 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.
 
Ranch Hand
Posts: 136
  • 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:
 
Ranch Hand
Posts: 641
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!