Re: about getRemoteHost()

2002-10-18 Thread Clayton Nash
Actually, there are many cases where the router changes the FROM address --
Network Address Translation (NAT) does just this. Those home ADSL networks
with many computers often do this kind of translation (it's reversed when
the packet comes back). It's also not uncommon for remote offices to have
this kind of translation as well.

It's best these days to assume that the IP address you see has nothing to do
with the user when dealing with the public Internet. Proxy Servers, NAT and
any number of other things mess with this.

Clayton

-Original Message-
From: A mailing list about Java Server Pages specification and reference
[mailto:JSP-INTEREST;JAVA.SUN.COM] On Behalf Of John Ghidiu
Sent: 17 October 2002 19:19
To: [EMAIL PROTECTED]
Subject: Re: about getRemoteHost()


In fact, if the router does change the FROM field, the TCP/IP connection is
effectively terminated because the receiving end can no longer reply (even
with an ACK) that the packet was received. However, a proxy is allowed to
(and often does) change the packet. Be aware of that in your programming
(which means, among other things, no session tracking via IP address).

John

-Original Message-
From: Peter Dolukhanov [mailto:peter.dolukhanov;NCL.AC.UK]
Sent: Wednesday, October 16, 2002 10:17 AM
To: [EMAIL PROTECTED]
Subject: Re: [JSP-INTEREST] about getRemoteHost()


From my knowledge of networking, a router (or routers) will not change the
From field of an IP packet, they just forward the packet onto a node closer
to it's destination. As even this e-mail bounces through umpteen routers,
and none of these will modify the remote address. So, as far I can tell this
won't happen - what you have to worry about is Web Proxies as these do send
the request to the web server themselves, and your web server will see them
as the remote host and not you.

Regards,
Peter Dolukhanov

-Original Message-
From: A mailing list about Java Server Pages specification and reference
[mailto:JSP-INTEREST;JAVA.SUN.COM] On Behalf Of randie ursal
Sent: 16 October 2002 03:07
To: [EMAIL PROTECTED]
Subject: about getRemoteHost()

hi,

i want some idea on this.

i have a setup where my WebServer is separated by a Router from a User.
when the user access the webserver it has to pass through the router, so
my
question is what would be return by the method getRemoteHost()?

is it the IP address of the Router or the User Workstation?

thanks a lot.
  randie


===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff
JSP-INTEREST. For digest: mailto [EMAIL PROTECTED] with body: set
JSP-INTEREST DIGEST. Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff
JSP-INTEREST. For digest: mailto [EMAIL PROTECTED] with body: set
JSP-INTEREST DIGEST. Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

=
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff
JSP-INTEREST. For digest: mailto [EMAIL PROTECTED] with body: set
JSP-INTEREST DIGEST. Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

==To 
unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



Re: obtaining date and time in suitable format for MySQL

2002-10-18 Thread Ionel Condor
No way Hugo !!!
You should use the java.util.GregorianCalendar class , as follows:
code
Calendar calendar = new GregorianCalendar();
 Date trialTime = new Date();
 calendar.setTime(trialTime);
System.out.println(YEAR: +calendar.get(Calendar.YEAR));
here your code...
/code

For any reference, please consult
http://java.sun.com/j2se/1.3/docs/api/java/util/GregorianCalendar.html
and you will find all the methods() that you need.

Regards,
Ionel Condor.


- Original Message -
From: hugo [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, October 18, 2002 6:23 AM
Subject: obtaining date and time in suitable format for MySQL


 Hi

 I am javing a jsp file where I would like to get the current date and
 time to be inserted in fields of an SQL table. The date should go into
 the MySQL date field and hence should be of format -mm-dd. I tried
 to use java.sql.Date, but I couldn't get it to work. If I simply use

 long date = 0;
 java.sql.Date sqlDate = new java.sql.Date(date);
 int year = sqlDate.getYear();

 I get back 70. So obviously I have to get the year from the machine's
 time, which is a linux box with Redhat 7.3.

 So I tried this:

 long date = 0;
 java.sql.Date sqlDate = new java.sql.Date(date);
 String thetime = sqlDate(System.currentTimeinMillis());
 out.println (SQL time is  + thetime);

 But this didn't work either.

 How do you do this?

 In addition, I would like to get the time, but in decimal format i.e.
 rather than 11:15 I would like to get 11.25

 Is there a way of doing this?

 Any help will be greatly appreciated.

 Thanks

 Hugo
 --
 Dr Hugo Bouckaert
 Systems and Programming Engineer

 GeoInformatics Exploration Australia P/L
 57 Havelock St
 West Perth, WA 6005
 PO Box 1675, West Perth 6872

 Ph:   61 08 9420 7400
 Fax:  61 08 9226 1299

 www.geoinformex.com

 
 This email and any attachments may be confidential or legally
 privileged. If you received this message in error or are not the
 intended recipient, you should destroy the e-mail message and any
 attachments or copies, and you are prohibited from retaining,
 distributing, disclosing or using any information contained herein.
 Please inform us of the erroneous delivery by return e-mail. Thank you
 for your cooperation.


===
 To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff
JSP-INTEREST.
 For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST
DIGEST.
 Some relevant FAQs on JSP/Servlets can be found at:

  http://archives.java.sun.com/jsp-interest.html
  http://java.sun.com/products/jsp/faq.html
  http://www.esperanto.org.nz/jsp/jspfaq.jsp
  http://www.jguru.com/faq/index.jsp
  http://www.jspinsider.com

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



Re: obtaining date and time in suitable format for MySQL

2002-10-18 Thread V.T.R.Ravi Kumar
Try this


%@ page language=java import=java.sql.*, java.io.*, java.util.*,
javax.servlet.http.*%
%@ page import=java.util.Date,java.util.Locale,java.text.*%
%
Date today;
String dd=,yy=,mm=,td=;
today=new Date();
Locale cl=new Locale(en,US);
SimpleDateFormat sf=new SimpleDateFormat(dd.MM.,cl);
td=sf.format(today);
dd=td.substring(0,2);
mm=td.substring(3,5);
yy=td.substring(6);
%

V.T.R.Ravi Kumar
Engineer,CCX,BHEL, Haridwar
Phone : Office-91-0133-485260
 Res   -91-0133-426121
-
- Original Message -
From: hugo [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, October 18, 2002 9:53 AM
Subject: obtaining date and time in suitable format for MySQL


 Hi

 I am javing a jsp file where I would like to get the current date and
 time to be inserted in fields of an SQL table. The date should go into
 the MySQL date field and hence should be of format -mm-dd. I tried
 to use java.sql.Date, but I couldn't get it to work. If I simply use

 long date = 0;
 java.sql.Date sqlDate = new java.sql.Date(date);
 int year = sqlDate.getYear();

 I get back 70. So obviously I have to get the year from the machine's
 time, which is a linux box with Redhat 7.3.

 So I tried this:

 long date = 0;
 java.sql.Date sqlDate = new java.sql.Date(date);
 String thetime = sqlDate(System.currentTimeinMillis());
 out.println (SQL time is  + thetime);

 But this didn't work either.

 How do you do this?

 In addition, I would like to get the time, but in decimal format i.e.
 rather than 11:15 I would like to get 11.25

 Is there a way of doing this?

 Any help will be greatly appreciated.

 Thanks

 Hugo
 --
 Dr Hugo Bouckaert
 Systems and Programming Engineer

 GeoInformatics Exploration Australia P/L
 57 Havelock St
 West Perth, WA 6005
 PO Box 1675, West Perth 6872

 Ph:   61 08 9420 7400
 Fax:  61 08 9226 1299

 www.geoinformex.com

 
 This email and any attachments may be confidential or legally
 privileged. If you received this message in error or are not the
 intended recipient, you should destroy the e-mail message and any
 attachments or copies, and you are prohibited from retaining,
 distributing, disclosing or using any information contained herein.
 Please inform us of the erroneous delivery by return e-mail. Thank you
 for your cooperation.


===
 To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff
JSP-INTEREST.
 For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST
DIGEST.
 Some relevant FAQs on JSP/Servlets can be found at:

  http://archives.java.sun.com/jsp-interest.html
  http://java.sun.com/products/jsp/faq.html
  http://www.esperanto.org.nz/jsp/jspfaq.jsp
  http://www.jguru.com/faq/index.jsp
  http://www.jspinsider.com


===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



Re: obtaining date and time in suitable format for MySQL

2002-10-18 Thread Michael
Dont format the date by hand!!!
Use a PreparedStatement to write to the database, it handles the formatting 
for you.
e.g.:

long curTime = new java.util.Date().getTime();

Connection connection= ... ;
PreparedStatement pstmt = connection.prepareStatement(
  update bla set time = ?);
pstmt.setDate( 1 ,new java.sql.Date( curTime ));
//...


 I am javing a jsp file where I would like to get the current date and
 time to be inserted in fields of an SQL table. The date should go into
 the MySQL date field and hence should be of format -mm-dd. I tried
 to use java.sql.Date, but I couldn't get it to work. If I simply use

 long date = 0;
 java.sql.Date sqlDate = new java.sql.Date(date);
 int year = sqlDate.getYear();

 I get back 70. So obviously I have to get the year from the machine's
 time, which is a linux box with Redhat 7.3.

 So I tried this:

 long date = 0;
 java.sql.Date sqlDate = new java.sql.Date(date);
 String thetime = sqlDate(System.currentTimeinMillis());
 out.println (SQL time is  + thetime);

 But this didn't work either.

 How do you do this?

 In addition, I would like to get the time, but in decimal format i.e.
 rather than 11:15 I would like to get 11.25

 Is there a way of doing this?

 Any help will be greatly appreciated.

 Thanks

 Hugo

==To 
unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



User log from JSP

2002-10-18 Thread Campano, Troy
I want to track each page a user goes to in a database from my JSP web app.

What I use to do is at the top of every page I would capture the user and page 
information and do an insert into the database.
But it seems that doing an insert into the database on every page load might be a 
little inefficient.

Does anyone have an idea on how to capture these stats?



thank you!


~ Troy Campano

==To 
unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



Re: User log from JSP

2002-10-18 Thread Padhu Vinirs
If you dont want to do a search, you could just log the info ( call
ServletContext.log() ). If not, you could collect the info in a context
attribute, and periodically submit all the requests ( like once in 4
hours ) together to a database.

-- padhu


Campano, Troy wrote:


I want to track each page a user goes to in a database from my JSP web app.

What I use to do is at the top of every page I would capture the user and page information and do an insert into the database.
But it seems that doing an insert into the database on every page load might be a little inefficient.

Does anyone have an idea on how to capture these stats?



thank you!


~ Troy Campano

=
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com





===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com



Re: UTF8 conversion - send mails from database : failUTF8Conv

2002-10-18 Thread KEITH KOSMICKI
Actually I think it's Japanese, try this site Looks like good info:
http://tech.ymirlink.co.jp/perl/cpan/Unicode-Japanese-0.03/Japanese.html 
Let me know how it turns out. sounds interesting.
 
 
 
Keith E. Kosmicki
Applications Consultant
State of IL Human Services
STL Technology Partners

 [EMAIL PROTECTED] 10/18/02 08:45AM 
Hi All,

We have an application which checks an oracle database and a servlet sends
out the mails at regular intervals based on the status whether the message
was sent or not.
The application has been running fine until now for abt 10 months. But today
morning we noticed that all mailing services had stopped. When we
investigated further we found that there was one message which was holding
the entire queue and none of the mails posted after that were being sent.
On checking the logs we found this error.  Fail to convert between UTF8 and
UCS2: failUTF8Conv
Apparently it talks abt chracter set conversion in the database. The message
that was blocking was in some other language other than english, possibly
french. And we use Oracle 8 thin drivers to connect to the database and the
jdk version is jdk1.2.2.

Has somebody faced the same problem and is there any solution to this.. I
did check each of the sites Google fished out to me.. but they only talk
more about the problem rather than the solution to the problem.
Please help me with this problem..

Here is the content of the log file..

java.sql.SQLException: Fail to convert between UTF8 and UCS2: failUTF8Conv
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.init(Compiled Code)
at java.lang.Exception.init(Compiled Code)
at java.sql.SQLException.init(SQLException.java:43)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:775)
at
oracle.jdbc.dbaccess.DBConversion.failUTF8Conv(DBConversion.java:1746)
at oracle.jdbc.dbaccess.DBConversion.utf8BytesToJavaChars(Compiled
Code)
at oracle.jdbc.dbaccess.DBConversion.utf8BytesToString(Compiled
Code)
at oracle.jdbc.dbaccess.DBConversion.CharBytesToString(Compiled
Code)
at oracle.jdbc.driver.OracleStatement.getStringValue(Compiled Code)
at oracle.jdbc.driver.OracleStatement.getObjectValue(Compiled Code)
at oracle.jdbc.driver.OracleStatement.getObjectValue(Compiled Code)
at oracle.jdbc.driver.OracleResultSetImpl.getObject(Compiled Code)
at sun.jdbc.rowset.CachedRowSet.populate(Compiled Code)
at com.sapient.core.sql.SQLCachedRowSet.populate(Compiled Code)
at com.sapient.core.sql.SQLWrapper.executeQueryStoredProc(Compiled
Code)
at com.sapient.core.sql.SQLWrapper.executeQueryStoredProc(Compiled
Code)
at com.edward.mailwrapper.MailUtil.getUnsentMailsParameters(Compiled
Code)
at com.edward.mailwrapper.MailService.performScheduledTask(Compiled
Code)
at atg.service.scheduler.ScheduledJob.runJobs(Compiled Code)
at atg.service.scheduler.Scheduler$2$handler.run(Scheduler.java:694)
MessageFail to convert between UTF8 and UCS2: failUTF8Conv
SQLCode17037   SQLState   null
--Thu Oct 17 18:42:24 GMT+01:00 2002--mailWrapper--
com.edward.mailwrapper--MailService--performScheduledTask--Mail
Wrapper--1--com.sapient.core.sql.GeneralSQLException
ERRORID608 PACKAGEcom.sapient.core.sqlMODULE
CORECLASS  SQLCachedRowSet FUNC
TION   populate(ResultSet rset) throws GeneralSQLException
ERRORTEXT: Exception occured using SQLCachedRowSet. EXTRAMESSAGE: Unable
to populate the CachedRowSet from the ResultSetINCOMING:
java.sql.SQLException: Fail to convert between UTF8 and UCS2: failUTF8Conv

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

http://archives.java.sun.com/jsp-interest.html 
http://java.sun.com/products/jsp/faq.html 
http://www.esperanto.org.nz/jsp/jspfaq.jsp 
http://www.jguru.com/faq/index.jsp 
http://www.jspinsider.com 

==To 
unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



Re: Pausing execution?

2002-10-18 Thread Dmitry Namiot
See for example Delay tag in Coldtags suite:
http://www.servletsuite.com/jsp.htm

--
Coldbeans Software - server-side Java (tm) components
http://www.servletsuite.com


__
The NEW Netscape 7.0 browser is now available. Upgrade now! 
http://channels.netscape.com/ns/browsers/download.jsp

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



Database Access Using Tags

2002-10-18 Thread rvt
Hi,

I seem to recall reading on one of the user lists (maybe this one) that
using taglibs for connecting to the database was not a good idea, for
security reasons.  The consensus was that it was at least better than
embedding Java scrptlets in your JSP.

I've been scouring the Net trying to figure out the best way to get a
database connection.  I'm using JSPs for the view, but I want to keep as
much Java code out of the pages as possible, since that results in a much
cleaner and easier to maintain application.  But I'm a newbie when it comes
to model 2.  I've written a site before using just JSP with Dreamweaver UD4.
But with what I'm working on now, that is not good enough.

I've got Tomcat set up, and I'm trying to use connection pooling.  I know
that I can use JNDI and Tomcat to look after the connection pooling details,
though I'm tearing my hair out trying to figure out how it all works and if
I've got all the pieces in place that I need.

My question/plea for input here is regarding what I should be using to write
the actual connection in.  If tags are not recommended, then should I be
using a class, a bean, or a servlet to do that work?  I read recently (I've
been doing a LOT of reading) that tags are a replacement for beans--though
that sort of conflicts with the point that I read before that tags are only
one step up from using scriptlets.  I'm starting to conclude that I should
be using a servlet, but I would really appreciate some confirmation from
people who are experienced with all this.

Also, is it possible/necessary to try to make the structure of the Web
application object oriented?  If I'm using JSP, does that negate the need
for creating an object oriented design--does it make that kind of a design,
even though I'm using Java, impossible to really do?

Thank you for any input.  I'm trying to get all these concepts straight in
my head, and the information out there is not only conflicting, but a little
overwhelming.

Val

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



Re: Database Access Using Tags

2002-10-18 Thread Jim Rueschhoff
If you want to avoid a typical MVC structure and having all your logic in
Servlets instead of JSP files (which is what I would suggest you do), you
can abstract your database accesses in classes that do all the work and only
have the class method calls within our JSP code.   That way you do not need
to have the database implementation code visible in the JSP and you can
reuse the classes in multiple JSP files.   Create all the database access
classes in a package and include that package in each JSP.  It is not as
well structured as a MVC type of structure but it does a reasonable job of
isolating your database access from the JSP.   If you create your classes
properly you can make your JSP code independent of the database being used
and thus allow it to be very portable.   You can also make the classes
centered around functionality as opposed to being table specific, thus
granting you more freedom for future modifications.

This will keep the object oriented design valid without having to use MVC.
However, it is an inferior approach and should be used with caution and only
in simple applications.



-Original Message-
From: A mailing list about Java Server Pages specification and reference
[mailto:JSP-INTEREST;JAVA.SUN.COM]On Behalf Of rvt
Sent: Friday, October 18, 2002 8:25 AM
To: [EMAIL PROTECTED]
Subject: [JSP-INTEREST] Database Access Using Tags


Hi,

I seem to recall reading on one of the user lists (maybe this one) that
using taglibs for connecting to the database was not a good idea, for
security reasons.  The consensus was that it was at least better than
embedding Java scrptlets in your JSP.

I've been scouring the Net trying to figure out the best way to get a
database connection.  I'm using JSPs for the view, but I want to keep as
much Java code out of the pages as possible, since that results in a much
cleaner and easier to maintain application.  But I'm a newbie when it comes
to model 2.  I've written a site before using just JSP with Dreamweaver UD4.
But with what I'm working on now, that is not good enough.

I've got Tomcat set up, and I'm trying to use connection pooling.  I know
that I can use JNDI and Tomcat to look after the connection pooling details,
though I'm tearing my hair out trying to figure out how it all works and if
I've got all the pieces in place that I need.

My question/plea for input here is regarding what I should be using to write
the actual connection in.  If tags are not recommended, then should I be
using a class, a bean, or a servlet to do that work?  I read recently (I've
been doing a LOT of reading) that tags are a replacement for beans--though
that sort of conflicts with the point that I read before that tags are only
one step up from using scriptlets.  I'm starting to conclude that I should
be using a servlet, but I would really appreciate some confirmation from
people who are experienced with all this.

Also, is it possible/necessary to try to make the structure of the Web
application object oriented?  If I'm using JSP, does that negate the need
for creating an object oriented design--does it make that kind of a design,
even though I'm using Java, impossible to really do?

Thank you for any input.  I'm trying to get all these concepts straight in
my head, and the information out there is not only conflicting, but a little
overwhelming.

Val

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff
JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST
DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



Re: Database Access Using Tags

2002-10-18 Thread Borislav Iordanov
Val,


 I seem to recall reading on one of the user lists (maybe this one)
that
 using taglibs for connecting to the database was not a good idea, for
 security reasons.  The consensus was that it was at least better than
 embedding Java scrptlets in your JSP.


The main reason accessing a database through tags is better than Java
scriptlets is that the code is simpler and cleaner. From an
architecture/design point of view, both approaches can be considered
equivalent.

The main reason NOT to access a database in the JSPs is separating
business logic from presentation, given that you consider JSPs as
presentation only technology (strange as it may seem, not everybody
does!). And Model 2 is one approach to that, the most popular one, but
not necessarily the best.

 My question/plea for input here is regarding what I should be using to
 write
 the actual connection in.  If tags are not recommended, then should I
be
 using a class, a bean, or a servlet to do that work?  I read recently
 (I've
 been doing a LOT of reading) that tags are a replacement for
beans--though
 that sort of conflicts with the point that I read before that tags are
 only
 one step up from using scriptlets.  I'm starting to conclude that I
should
 be using a servlet, but I would really appreciate some confirmation
from
 people who are experienced with all this.


First, tags are not a replacement for beans, I wonder where you read
that ;) Tags are means for providing abstractions/encapsulating
functionality, be it business logic or presentation related, that is
accessible through an XML-based syntax in a JSP page. That's pretty much
all tags are.

If you want to separate presentation from the business logic, the first
thing you should do is encapsulate the business logic in Java beans.
Those Java beans will work with the database to
access/store/update/delete data. And the JSPs will use those Java beans
to get the information to display.

When it comes to getting input from the end-user and storing it in the
database, you will need to somehow set the bean properties from a
submitted HTML form and tell the bean to write its information to the
database (e.g. something like mybean.insert() or mybean.update). Again,
the Java bean deals with database access and your presentation layer
deals only with the Java bean. Most JSP/Servlets frameworks map
submitted form fields to bean properties automatically. Struts (the most
popular Model 2 framework) does that, even though it limits the types of
your bean properties to primitive Java types. Our product TICL does it
also.

All this is pretty much standard practice...


 Also, is it possible/necessary to try to make the structure of the Web
 application object oriented?  If I'm using JSP, does that negate the
need
 for creating an object oriented design--does it make that kind of a
 design,
 even though I'm using Java, impossible to really do?


It is possible and good practice to have your web application be
object-oriented. However, JSPs make that very difficult, because they
can't be sub-classed. By encapsulating the business logic of your
application in Java beans, you have at least that be object-oriented.
The presentation logic can be made object-oriented, or close to, by
using one of the available UI frameworks.

Cheers,
Boris


Borislav Iordanov
Chief Architect
TICL - a RAD toolkit for server-side Java
http://www.kobrix.com

 -Original Message-
 From: A mailing list about Java Server Pages specification and
reference
 [mailto:JSP-INTEREST;JAVA.SUN.COM] On Behalf Of rvt
 Sent: Friday, October 18, 2002 11:25 AM
 To: [EMAIL PROTECTED]
 Subject: Database Access Using Tags

 Hi,
 I've been scouring the Net trying to figure out the best way to get a
 database connection.  I'm using JSPs for the view, but I want to keep
as
 much Java code out of the pages as possible, since that results in a
much
 cleaner and easier to maintain application.  But I'm a newbie when it
 comes
 to model 2.  I've written a site before using just JSP with
Dreamweaver
 UD4.
 But with what I'm working on now, that is not good enough.

 I've got Tomcat set up, and I'm trying to use connection pooling.  I
know
 that I can use JNDI and Tomcat to look after the connection pooling
 details,
 though I'm tearing my hair out trying to figure out how it all works
and
 if
 I've got all the pieces in place that I need.

 My question/plea for input here is regarding what I should be using to
 write
 the actual connection in.  If tags are not recommended, then should I
be
 using a class, a bean, or a servlet to do that work?  I read recently
 (I've
 been doing a LOT of reading) that tags are a replacement for
beans--though
 that sort of conflicts with the point that I read before that tags are
 only
 one step up from using scriptlets.  I'm starting to conclude that I
should
 be using a servlet, but I would really appreciate some confirmation
from
 people who are experienced with all 

Jar files

2002-10-18 Thread Paul Toyn
Hi,

I'm not quite sure where to put my JAR files.  I'm using Tomcat 4.0.6
and my directory structure is
c:\jakarta-tomcat-4.0.6\webapps\ROOT\WEB-INF\Timeslp\Timeslip2.jsp

A snippet of my code is:

%
Class.forName(com.jnetdirect.jsql.JSQLDriver);
conn =
jdbc:JSQLConnect://168.179.185.19/database=Timeslip/user=timeslip/password=timeslip;
Connection Conn = DriverManager.getConnection(conn); ...

Where do I put the JSQConnect.jar file so the class is recognized?

My classpath is:

.;C:\JSPDevelopment;C:\jakarta-tomcat-4.0.6\common\lib\servlet.jar;c:\jakarta-tomcat-4.0.6\webapps\root\web-inf\classes;c:\jakarta-tomcat-4.0.6\webapps\root\timeslip\web-inf\classes

What am I doing wrong?

Thanks in advance

Paul

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



Re: Database Access Using Tags

2002-10-18 Thread rvt
Thank you, everyone who replied.

Just one clarification:  Boris, did you mean EJBs when you said Java
Beans?  I would rather not use EJBs.  I'm only using a Web container, not
an application server.  Also, if what you're referring to are just regular
beans, would they be in a package?  I know that is probably a stupid
question, but I have never used beans before, and two developers I've spoken
to in the past have warned me away from EJBs, so when I was planning this
particular project, I was not even considering EJBs.

Jim's suggestion that I package classes and access the methods from the JSPs
sounded like a nice, simple, clean way to do things.  His caveat was that it
should be used with caution, and for simple applications.  If an application
were not so simple (and right now, the one I'm working on is), would Java
Beans then be the better alternative, if I were able to acquire the
knowledge I needed to use them?

By the way, I read that Taglibs are the next evolution from Java Beans and
that it is better to use them, in a posting on a user list.  I belong to a
number of them, and I can't say which one it was.  But perhaps my
paraphrasing of what was said there is inaccurate.  I did, however, get an
impression from reading it that Tag libraries make using beans obsolete,
though that might not have been the author's intent.  I guess that's how
rumours get started.  ;-)

I do really appreciate all the knowledge that is being shared on these
lists.  I'd be lost without them, and it sure helps to have such
misconceptions cleared up.

Val

- Original Message -
From: Borislav Iordanov [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, October 18, 2002 12:20 PM
Subject: Re: Database Access Using Tags


Val,


 I seem to recall reading on one of the user lists (maybe this one)
that
 using taglibs for connecting to the database was not a good idea, for
 security reasons.  The consensus was that it was at least better than
 embedding Java scrptlets in your JSP.


The main reason accessing a database through tags is better than Java
scriptlets is that the code is simpler and cleaner. From an
architecture/design point of view, both approaches can be considered
equivalent.

The main reason NOT to access a database in the JSPs is separating
business logic from presentation, given that you consider JSPs as
presentation only technology (strange as it may seem, not everybody
does!). And Model 2 is one approach to that, the most popular one, but
not necessarily the best.

 My question/plea for input here is regarding what I should be using to
 write
 the actual connection in.  If tags are not recommended, then should I
be
 using a class, a bean, or a servlet to do that work?  I read recently
 (I've
 been doing a LOT of reading) that tags are a replacement for
beans--though
 that sort of conflicts with the point that I read before that tags are
 only
 one step up from using scriptlets.  I'm starting to conclude that I
should
 be using a servlet, but I would really appreciate some confirmation
from
 people who are experienced with all this.


First, tags are not a replacement for beans, I wonder where you read
that ;) Tags are means for providing abstractions/encapsulating
functionality, be it business logic or presentation related, that is
accessible through an XML-based syntax in a JSP page. That's pretty much
all tags are.

If you want to separate presentation from the business logic, the first
thing you should do is encapsulate the business logic in Java beans.
Those Java beans will work with the database to
access/store/update/delete data. And the JSPs will use those Java beans
to get the information to display.

When it comes to getting input from the end-user and storing it in the
database, you will need to somehow set the bean properties from a
submitted HTML form and tell the bean to write its information to the
database (e.g. something like mybean.insert() or mybean.update). Again,
the Java bean deals with database access and your presentation layer
deals only with the Java bean. Most JSP/Servlets frameworks map
submitted form fields to bean properties automatically. Struts (the most
popular Model 2 framework) does that, even though it limits the types of
your bean properties to primitive Java types. Our product TICL does it
also.

All this is pretty much standard practice...


 Also, is it possible/necessary to try to make the structure of the Web
 application object oriented?  If I'm using JSP, does that negate the
need
 for creating an object oriented design--does it make that kind of a
 design,
 even though I'm using Java, impossible to really do?


It is possible and good practice to have your web application be
object-oriented. However, JSPs make that very difficult, because they
can't be sub-classed. By encapsulating the business logic of your
application in Java beans, you have at least that be object-oriented.
The presentation logic can be made object-oriented, or close to, by ᚠsng one of 

Re: Database Access Using Tags

2002-10-18 Thread Borislav Iordanov
Val,

I meant regular beans, not EJBs. Java beans are Java classes that adhere
to certain naming conventions. But you'll have to do your homework on
that;)

Jim's comments and mine about a Java beans layer on top of the database
said essentially the same thing, but in a different way.

Cheers,
Boris


Borislav Iordanov
Chief Architect
TICL - a RAD toolkit for server-side Java
http://www.kobrix.com

 -Original Message-
 From: A mailing list about Java Server Pages specification and
reference
 [mailto:JSP-INTEREST;JAVA.SUN.COM] On Behalf Of rvt
 Sent: Friday, October 18, 2002 2:29 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Database Access Using Tags
 
 Thank you, everyone who replied.
 
 Just one clarification:  Boris, did you mean EJBs when you said Java
 Beans?  I would rather not use EJBs.  I'm only using a Web container,
not
 an application server.  Also, if what you're referring to are just
regular
 beans, would they be in a package?  I know that is probably a stupid
 question, but I have never used beans before, and two developers I've
 spoken
 to in the past have warned me away from EJBs, so when I was planning
this
 particular project, I was not even considering EJBs.
 
 Jim's suggestion that I package classes and access the methods from
the
 JSPs
 sounded like a nice, simple, clean way to do things.  His caveat was
that
 it
 should be used with caution, and for simple applications.  If an
 application
 were not so simple (and right now, the one I'm working on is), would
Java
 Beans then be the better alternative, if I were able to acquire the
 knowledge I needed to use them?
 
 By the way, I read that Taglibs are the next evolution from Java Beans
and
 that it is better to use them, in a posting on a user list.  I belong
to a
 number of them, and I can't say which one it was.  But perhaps my
 paraphrasing of what was said there is inaccurate.  I did, however,
get an
 impression from reading it that Tag libraries make using beans
obsolete,
 though that might not have been the author's intent.  I guess that's
how
 rumours get started.  ;-)
 
 I do really appreciate all the knowledge that is being shared on these
 lists.  I'd be lost without them, and it sure helps to have such
 misconceptions cleared up.
 
 Val
 
 - Original Message -
 From: Borislav Iordanov [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, October 18, 2002 12:20 PM
 Subject: Re: Database Access Using Tags
 
 
 Val,
 
 
  I seem to recall reading on one of the user lists (maybe this one)
 that
  using taglibs for connecting to the database was not a good idea,
for
  security reasons.  The consensus was that it was at least better
than
  embedding Java scrptlets in your JSP.
 
 
 The main reason accessing a database through tags is better than Java
 scriptlets is that the code is simpler and cleaner. From an
 architecture/design point of view, both approaches can be considered
 equivalent.
 
 The main reason NOT to access a database in the JSPs is separating
 business logic from presentation, given that you consider JSPs as
 presentation only technology (strange as it may seem, not everybody
 does!). And Model 2 is one approach to that, the most popular one, but
 not necessarily the best.
 
  My question/plea for input here is regarding what I should be using
to
  write
  the actual connection in.  If tags are not recommended, then should
I
 be
  using a class, a bean, or a servlet to do that work?  I read
recently
  (I've
  been doing a LOT of reading) that tags are a replacement for
 beans--though
  that sort of conflicts with the point that I read before that tags
are
  only
  one step up from using scriptlets.  I'm starting to conclude that I
 should
  be using a servlet, but I would really appreciate some confirmation
 from
  people who are experienced with all this.
 
 
 First, tags are not a replacement for beans, I wonder where you read
 that ;) Tags are means for providing abstractions/encapsulating
 functionality, be it business logic or presentation related, that is
 accessible through an XML-based syntax in a JSP page. That's pretty
much
 all tags are.
 
 If you want to separate presentation from the business logic, the
first
 thing you should do is encapsulate the business logic in Java beans.
 Those Java beans will work with the database to
 access/store/update/delete data. And the JSPs will use those Java
beans
 to get the information to display.
 
 When it comes to getting input from the end-user and storing it in the
 database, you will need to somehow set the bean properties from a
 submitted HTML form and tell the bean to write its information to the
 database (e.g. something like mybean.insert() or mybean.update).
Again,
 the Java bean deals with database access and your presentation layer
 deals only with the Java bean. Most JSP/Servlets frameworks map
 submitted form fields to bean properties automatically. Struts (the
most
 popular Model 2 

Re: Question on documentation...

2002-10-18 Thread Luis A
Man, you must be kidding. So the tutorial I just wrote and emailed to my 32
students will not work without the web.xml changes? Are you sure?

Please reply.

Thanks,

Luis.


- Original Message -
From: Hans Bergsten [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, October 17, 2002 2:58 PM
Subject: Re: Question on documentation...


 Paul Toyn wrote:
  The following is a snippet from the Jakarta-Tomcat configuration and
  testing documentation:
 
  Once you compile HelloServlet.java, put HelloServlet.class in
  install_dir/webapps/ROOT/WEB-INF/classes. After compiling the code,
  access the servlet with the URL http://localhost/servlet/HelloServlet
  ... You should get a simple HTML page that says Hello. If this URL
  fails but the test of the server itself succeeded, you probably put the
  class file in the wrong directory.
 
  I've followed the example and everything is working up to the point
  above.   I compiled the java code and it compiled without a hitch, but I
  do get a 404 error when I try the URL. The test of the server did
  succeed.  I placed the class file into the folder as indicated.   Is the
  documentation correct?  Where does the folder servlet get involved?
  What am I doing wrong?

 Is this with Tomcat 4.1.12? If so, it's because the invoker (the
 servlet mapped to the /servlet/* path) is disabled by default starting
 with this version due to security concerns. See the release notes for
 details.

 In general, you should use explicit mappings for all servlets instead
 of using the invoker. Add this to the web.xml file for the application
 (e.g. webapps/ROOT/WEB-INF/web.xml for the Tomcat default application):

servlet
  servlet-namehello/servlet-name
  servlet-classHelloServlet/servlet-class
/servlet
...
servlet-mapping
  servlet-namehello/servlet-name
  url-pattern/hello/*/url-pattern
/servlet-mapping

 After restarting the web container (Tomcat), you can use a URL like
 this to invoke it:

http://localhost:8080/hello

 Hans
 --
 Hans Bergsten   [EMAIL PROTECTED]
 Gefion Software http://www.gefionsoftware.com
 JavaServer Pageshttp://TheJSPBook.com


===
 To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff
JSP-INTEREST.
 For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST
DIGEST.
 Some relevant FAQs on JSP/Servlets can be found at:

  http://archives.java.sun.com/jsp-interest.html
  http://java.sun.com/products/jsp/faq.html
  http://www.esperanto.org.nz/jsp/jspfaq.jsp
  http://www.jguru.com/faq/index.jsp
  http://www.jspinsider.com


===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



UTF8 conversion - send mails from database : failUTF8Conv

2002-10-18 Thread Anoop Kumar V
Hi All,

We have an application which checks an oracle database and a servlet sends
out the mails at regular intervals based on the status whether the message
was sent or not.
The application has been running fine until now for abt 10 months. But today
morning we noticed that all mailing services had stopped. When we
investigated further we found that there was one message which was holding
the entire queue and none of the mails posted after that were being sent.
On checking the logs we found this error.  Fail to convert between UTF8 and
UCS2: failUTF8Conv
Apparently it talks abt chracter set conversion in the database. The message
that was blocking was in some other language other than english, possibly
french. And we use Oracle 8 thin drivers to connect to the database and the
jdk version is jdk1.2.2.

Has somebody faced the same problem and is there any solution to this.. I
did check each of the sites Google fished out to me.. but they only talk
more about the problem rather than the solution to the problem.
Please help me with this problem..

Here is the content of the log file..

java.sql.SQLException: Fail to convert between UTF8 and UCS2: failUTF8Conv
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.init(Compiled Code)
at java.lang.Exception.init(Compiled Code)
at java.sql.SQLException.init(SQLException.java:43)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:775)
at
oracle.jdbc.dbaccess.DBConversion.failUTF8Conv(DBConversion.java:1746)
at oracle.jdbc.dbaccess.DBConversion.utf8BytesToJavaChars(Compiled
Code)
at oracle.jdbc.dbaccess.DBConversion.utf8BytesToString(Compiled
Code)
at oracle.jdbc.dbaccess.DBConversion.CharBytesToString(Compiled
Code)
at oracle.jdbc.driver.OracleStatement.getStringValue(Compiled Code)
at oracle.jdbc.driver.OracleStatement.getObjectValue(Compiled Code)
at oracle.jdbc.driver.OracleStatement.getObjectValue(Compiled Code)
at oracle.jdbc.driver.OracleResultSetImpl.getObject(Compiled Code)
at sun.jdbc.rowset.CachedRowSet.populate(Compiled Code)
at com.sapient.core.sql.SQLCachedRowSet.populate(Compiled Code)
at com.sapient.core.sql.SQLWrapper.executeQueryStoredProc(Compiled
Code)
at com.sapient.core.sql.SQLWrapper.executeQueryStoredProc(Compiled
Code)
at com.edward.mailwrapper.MailUtil.getUnsentMailsParameters(Compiled
Code)
at com.edward.mailwrapper.MailService.performScheduledTask(Compiled
Code)
at atg.service.scheduler.ScheduledJob.runJobs(Compiled Code)
at atg.service.scheduler.Scheduler$2$handler.run(Scheduler.java:694)
MessageFail to convert between UTF8 and UCS2: failUTF8Conv
SQLCode17037   SQLState   null
--Thu Oct 17 18:42:24 GMT+01:00 2002--mailWrapper--
com.edward.mailwrapper--MailService--performScheduledTask--Mail
Wrapper--1--com.sapient.core.sql.GeneralSQLException
ERRORID608 PACKAGEcom.sapient.core.sqlMODULE
CORECLASS  SQLCachedRowSet FUNC
TION   populate(ResultSet rset) throws GeneralSQLException
ERRORTEXT: Exception occured using SQLCachedRowSet. EXTRAMESSAGE: Unable
to populate the CachedRowSet from the ResultSetINCOMING:
java.sql.SQLException: Fail to convert between UTF8 and UCS2: failUTF8Conv

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: signoff JSP-INTEREST.
For digest: mailto [EMAIL PROTECTED] with body: set JSP-INTEREST DIGEST.
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com