RE: JSP help: A bit off topic

2003-01-03 Thread Laxmikanth M.S.
I don't see useBean Tag if u want to use a class use UseBean and call
the methos using the bean...


 -Original Message-
 From: Raj [SMTP:[EMAIL PROTECTED]]
 Sent: Friday, January 03, 2003 3:42 PM
 To:   Tomcat Users List
 Subject:  JSP help: A bit off topic
 
 Hi,
 This doesn't exactly relate to Tomcat, but it is a general JSP query. You
 see, I am using a set of Java classes, packaged as CTG (CICS Transaction
 Gateway) provided by IBM. My problem is, I am able to instantiate a CTG
 object inside the JSP. For example, in the JSP, if I write
  
 html
 blah blah blah
 %
 CTGClass ctgObject = blah blah blah
 
 .
 %
 b%=ctgObject.getSomeString()%b
  
  
 This works fine. But when I write all this code inside my class, and say
  
 html
 blah blah blah
 %
 myClass myObject;
 myObject.getSomeString() /* This will actually contain all the code in
 JSP, just to avoid the JSP page cluttered with Java Code */
  
 But this doesn't work. This problem is not only with CTG but many other
 classes, too. One interesting observation is, if I add a main to myClass
 and run it from the command prompt, it works perfectly.
 
 Any help?
 Raj
 File: InterScan_SafeStamp.txtFile: ATT12098.txt  
*
Disclaimer: The information in this e-mail and any attachments is
confidential / privileged. It is intended solely for the addressee or
addressees. If you are not the addressee indicated in this message, you may
not copy or deliver this message to anyone. In such case, you should destroy
this message and kindly notify the sender by reply email. Please advise
immediately if you or your employer does not consent to Internet email for
messages of this kind.
*

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: JSP help: A bit off topic

2003-01-03 Thread Mehdi . Nejad

Hi,

You should not *have* to use a useBean in order to instantiate a class.   I
did not see in the example you posted, where you actually created an
Object.. your code was :

 myClass myObject;
 myObject.getSomeString() /* This will actually contain all the code in
 JSP, just to avoid the JSP page cluttered with Java Code */

.. but no-where was there a myObject = new myClass();

ie :

myClass myObject = new myClass();
myObject.getSomeString()

until you do this, there is no object, just a ref, so you can't call
methods on it.

Thanks,

Mehdi Nejad



   
  
  Laxmikanth M.S.
  
  laxmikanth.ms@sonata-soTo:   Tomcat Users List 
[EMAIL PROTECTED]   
  ftware.com cc:  
  
  Subject:  RE: JSP help: A bit 
off topic
  03/01/2003 10:15 
  
  Please respond to
  
  Tomcat Users List  
  
   
  
   
  




I don't see useBean Tag if u want to use a class use UseBean and call
the methos using the bean...


 -Original Message-
 From:Raj [SMTP:[EMAIL PROTECTED]]
 Sent:Friday, January 03, 2003 3:42 PM
 To:Tomcat Users List
 Subject: JSP help: A bit off topic

 Hi,
 This doesn't exactly relate to Tomcat, but it is a general JSP query. You
 see, I am using a set of Java classes, packaged as CTG (CICS Transaction
 Gateway) provided by IBM. My problem is, I am able to instantiate a CTG
 object inside the JSP. For example, in the JSP, if I write

 html
 blah blah blah
 %
 CTGClass ctgObject = blah blah blah
 
 .
 %
 b%=ctgObject.getSomeString()%b


 This works fine. But when I write all this code inside my class, and say

 html
 blah blah blah
 %
 myClass myObject;
 myObject.getSomeString() /* This will actually contain all the code in
 JSP, just to avoid the JSP page cluttered with Java Code */

 But this doesn't work. This problem is not only with CTG but many other
 classes, too. One interesting observation is, if I add a main to myClass
 and run it from the command prompt, it works perfectly.

 Any help?
 Raj
 File: InterScan_SafeStamp.txtFile: ATT12098.txt 
*
Disclaimer: The information in this e-mail and any attachments is
confidential / privileged. It is intended solely for the addressee or
addressees. If you are not the addressee indicated in this message, you may
not copy or deliver this message to anyone. In such case, you should
destroy
this message and kindly notify the sender by reply email. Please advise
immediately if you or your employer does not consent to Internet email for
messages of this kind.
*

--
To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail: 
mailto:[EMAIL PROTECTED]






--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: JSP help: A bit off topic

2003-01-03 Thread Craig R. McClanahan


  myObject.getSomeString() /* This will actually contain all the code in
  JSP, just to avoid the JSP page cluttered with Java Code */

If you expect getSomeString() to return *JSP* code (including tags and
scriptlets and all), you can't do that.  The JSP code is compiled the
first time you execute this page -- you can't create it dynamically at
runtime.

At best, you could have getSomeString() return some static HTML code and
write it to the output stream:

%
  out.println(myObject.getSomeString());
%

However, embedding *any* of this stuff is really a misuse of the
technology, because you end up intermixing business logic (what data am
I manipulating) with presentation logic (how do I want this data to
look) in ways that will lead you into unmaintainable spaghetti code that
is very difficult to update later.

A far better strategy is to use some sort of MVC architecture (such as
Struts, http://jakarta.apache.org/struts/) and put your business logic in
Java classes, and your presentation logic in your JSP pages or whatever.
Let your business logic deal with the *data* (getting it from the
database or whatever) and your JSP page deal with the *UI* (how it appears
to the user).

Craig


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]