Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2004

Tip: Looking for answers? Try searching our database.

SQL in JSP

Thread view: 
Peter - 03 Feb 2004 08:00 GMT
Hi
  Please answer:

A database server which doesn't support stored procedure, How can we
hide the sql statement code in JSP? expecting writting those code in
servlet.

thanks
from Peter (cmk128@hotmail.com)
Thomas Kellerer - 03 Feb 2004 08:30 GMT
Peter schrieb:

> Hi
>    Please answer:
[quoted text clipped - 5 lines]
> thanks
> from Peter (cmk128@hotmail.com)

You should put your business logic into "normal" Java classes anyway, SQL
statements should not be in JSP pages.
Once you have your business logic in the Java classes, call those classes from
within your JSP.

But even if you put your SQL into the JSP it won't be visible on the client, as
the client will only see the generated HTML

Thomas
Peter - 05 Feb 2004 02:25 GMT
> Peter schrieb:
>
[quoted text clipped - 17 lines]
>
> Thomas

thanks for your opinion
  but i can use offline browser to download the jsp page. It is
better to write sql statement in servlet i think. Actually servlet is
better than jsp, i don't know why SUN have to make jsp too.

thanks
from Peter (cmk128@hotmail.com)
Tony Morris - 05 Feb 2004 02:37 GMT
> thanks for your opinion
>    but i can use offline browser to download the jsp page. It is
[quoted text clipped - 3 lines]
> thanks
> from Peter (cmk128@hotmail.com)

No, servlets are not better than JSP - both have their applications.
Generally, servlets perform business logic, while JSP provides presentation
to the end user.
Servlets generating presentation output (usually HTML) is a very nasty thing
to do, while embedding large amounts of Java code (business logic) in a JSP
is also very nasty.  A JSP is compiled to a servlet by the application
server, usually at first-request time (container dependant).

To perform raw database operations in a Servlet is very crude, and even more
so, in a JSP.
You might want to investigate the use of EJB or an O-R mapping tool such as
Hibernate.

Signature

Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)

Leo Gaggl - 05 Feb 2004 03:16 GMT
In your situation I would have a good look at some of the MVC frameworks
out there to properly structure your application and seperate
database/business logic/presentation. Might be a learning curve but well
worth it.

There are quite a few Jakarta Turbine, Jakarta Struts, Maverick ....

http://jakarta.apache.org/ should get you started. Or use Google to
search for "java mvc framework". These frameworks can integrate with a
number O/R tools or use JDBC directly.

HTH,

--

Leo Gaggl
Adelaide, South Australia
Mladen Adamovic - 07 Feb 2004 08:08 GMT
"Peter" <cmk128@hotmail.com> wrote :
>    but i can use offline browser to download the jsp page.

wrong!!!
you can not in every case offline use jsp - except of "dummy pure HTML JSP"

JSP run on the server, so when you use offline browser -  you just see in
browser result of JSP.

> better to write sql statement in servlet i think. Actually servlet is
> better than jsp, i don't know why SUN have to make jsp too.
>
> thanks
> from Peter (cmk128@hotmail.com)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.