hosted by liquidweb

Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Need help to create a Servlet

Forum Jump

Need help to create a Servlet

Reply Post New Thread In Programming Discussion Subscription
Send news tip View All Posts Thread Tools Search this Thread Display Modes
Join Date: Mar 2003
Posts: 23

Need help to create a Servlet

Hi guys,

I use the JSP code below to select stuff from a databse and display it in html.

Ideally I would like to do all the logice stuff in a servlet and display in the jsp page. I aint have a clue about servlets I keep on running into trouble. Could someone help me please!!!!
Also I don't want to use out.println in the servlet.

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%@ include file ="dbconnect.jsp" %>

String myQuery ="SELECT * FROM news_item WHERE source = 'Football365 UK' OR source = 'BBC Sports - Football' OR source = 'Sportinglife - Football' OR source = ' Football' OR source = 'Ananova: Sport' OR source = 'Google Sports News' ORDER BY date ASC ";
ResultSet rs = mystatement.executeQuery(myQuery);

String sTitle = "";
String sLink = "";
String sOutput = "";
String sDate = "";
String sSource = "";

for (int i=0; i<2; i++)

while (
sTitle = rs.getString("title");
sLink = rs.getString("link");
sDate = rs.getString("date");
sSource = rs.getString("source");
sOutput = sOutput+"<a href="+sLink+">"+sTitle+"</a><br>"+sDate+"<br>"+sSource+"<p>";

//********WORLD NEWS*************
String myQuery2 ="SELECT * FROM news_item WHERE source = 'AlterNet: War on Iraq' ORDER BY date ASC ";
ResultSet rs2 = mystatement.executeQuery(myQuery2);

String sTitle2 = "";
String sLink2 = "";
String sOutput2 = "";
String sDate2 = "";
String sSource2 = "";

while (

sTitle2 = rs2.getString("title");
sLink2 = rs2.getString("link");
sDate2 = rs2.getString("date");
sSource2 = rs2.getString("source");
sOutput2 = sOutput2+"<a href="+sLink2+">"+sTitle2+"</a><br>"+sDate2+"<br>"+sSource2+"<p>";


<body bgcolor="#FFFFFF" text="#000000">
<font size="1"></font>
Welcome IE Explorer User
<table width="55%" border="1" align="center">
<td width="50%"><%=sOutput %></td>
<td width="50%"><%=sOutput2 %></td>

Sponsored Links

Related posts from
Title Type Date Posted
Cirrus Hosting Lets Users Create Virtual Private Networks within Public Cloud Web Hosting News 2014-05-02 12:40:36
IBM Buys DBaaS Provider Cloudant, Opens Bluemix Cloud Platform to Public Web Hosting News 2014-02-24 18:27:54
UK Companies Need to Take Cybersecurity More Seriously: Government Report Web Hosting News 2013-11-27 11:32:54
.CO Internet Launches to Help Startups Get Online Fast Web Hosting News 2013-08-13 15:42:50
1&1 Internet Adds New SMB Tools to MyWebsite Web Hosting News 2013-03-25 16:29:43

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Log in with your username and password

Forgot Password?
WHT Host Brief Email:

We respect your privacy. We will never sell, rent, or give away your address to any outside party, ever.

Web Hosting News:
WHT Membership
WHT Membership



Welcome to

Create your username to jump into the discussion! is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.

(4 digit year)

Already a member?