Click here to Skip to main content
16,006,845 members
Home / Discussions / Java
   

Java

 
AnswerRe: Mozilla Firefox Pin
fly9044-Aug-09 7:29
fly9044-Aug-09 7:29 
Questionout of heap Exception Pin
shammasi31-Jul-09 20:24
shammasi31-Jul-09 20:24 
AnswerRe: out of heap Exception Pin
42774803-Aug-09 20:08
42774803-Aug-09 20:08 
GeneralRe: out of heap Exception Pin
shammasi3-Aug-09 20:51
shammasi3-Aug-09 20:51 
QuestionFingerprint Reader Pin
-=spike=-30-Jul-09 19:26
-=spike=-30-Jul-09 19:26 
GeneralRe: Fingerprint Reader Pin
Kujtim Hyseni31-Jul-09 2:50
Kujtim Hyseni31-Jul-09 2:50 
QuestionHow to respond/reply to a Server Cookie ? - trying to make a Java Web Browser. Pin
icyrohit30-Jul-09 18:31
icyrohit30-Jul-09 18:31 
QuestionDisplay Table in JSP Pin
<<Tash18>>30-Jul-09 2:50
<<Tash18>>30-Jul-09 2:50 
Hello Everyone,

Im using My Eclipse6.0 and have oracle10g express edition. Now actually im creating a simple web project in eclipse at first i created a package called con.avanza.test1 and added a class called TestDB1.java.
The following code is present in TestDB1.java :
package com.avanza.test1;
import java.sql.*;
import oracle.jdbc.*;

public class TestDB1 
{
	private Connection con;
	private PreparedStatement ps;
	private ResultSet rs;

	public void connect()
	{
	try
	{
	Class.forName("oracle.jdbc.OracleDriver");
        con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522:xe","system","admin");
	System.out.println("Connected.");
	}
	catch(Exception e)
	{
		e.getStackTrace();
	System.out.println(e);
	}
	}

	public void display()
	{
	try
	{
	ps = con.prepareStatement("select * from details");
	rs = ps.executeQuery();
	int count = 0;
	while(rs.next())
	{
	System.out.println("Name :: "+rs.getString(1)+" , Age :: "+rs.getString(2)+" , Phone No :: "+rs.getString(3));
	count++;
	}
	System.out.println(count+" records selected...");
	}
	catch(Exception e)
	{
	System.out.println(e);
	}
	}
	public static void main(String args[])
	{
		TestDB1 aa=new TestDB1();
		aa.connect();
		aa.display();
	}
}


On executing the above code the records in the DB gets displayed on the Console. Now Under the webroot is my JSP file called index.jsp
The coding in my JSP File is as follows:
<%@ page language="java" import="java.sql.*" pageEncoding="ISO-8859-1"%>
<%@ page import="com.avanza.test1.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
TestDB1 aa=new TestDB1();
aa.connect();
aa.display();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
 
  </body>
</html>


i have included my package in the above code, on running it with server i can see only a blank page in my browser but my records from my DB gets displayed on the console... I need My records to be displayed on the browser through my JSP page... Wat kind of changes should i implement on my Jsp page... Do help me with some sample codes.. I am a beginner in java... Do plzz help me...
Thanx in advance...
Cheers,
Thashif
AnswerRe: Display Table in JSP Pin
David Skelly30-Jul-09 22:19
David Skelly30-Jul-09 22:19 
AnswerRe: Display Table in JSP Pin
Centurion12351-Aug-09 21:07
Centurion12351-Aug-09 21:07 
GeneralRe: Display Table in JSP Pin
David Skelly2-Aug-09 22:31
David Skelly2-Aug-09 22:31 
AnswerRe: Display Table in JSP Pin
42774803-Aug-09 20:06
42774803-Aug-09 20:06 
AnswerRe: Display Table in JSP Pin
<<Tash18>>5-Aug-09 3:30
<<Tash18>>5-Aug-09 3:30 
Questioncan u help me Pin
soumyassdas29-Jul-09 23:38
soumyassdas29-Jul-09 23:38 
AnswerRe: can u help me Pin
Nagy Vilmos30-Jul-09 0:44
professionalNagy Vilmos30-Jul-09 0:44 
GeneralRe: can u help me Pin
soumyassdas6-Aug-09 19:17
soumyassdas6-Aug-09 19:17 
Questionurl download Pin
soumyassdas29-Jul-09 21:55
soumyassdas29-Jul-09 21:55 
AnswerRe: url download Pin
Nagy Vilmos29-Jul-09 22:23
professionalNagy Vilmos29-Jul-09 22:23 
AnswerRe: url download Pin
zhaonameloc30-Jul-09 4:26
zhaonameloc30-Jul-09 4:26 
GeneralRe: url download Pin
Nagy Vilmos30-Jul-09 4:47
professionalNagy Vilmos30-Jul-09 4:47 
Questioncan you help me? Pin
mehmetbilge29-Jul-09 1:55
mehmetbilge29-Jul-09 1:55 
AnswerRe: can you help me? Pin
Nagy Vilmos29-Jul-09 2:13
professionalNagy Vilmos29-Jul-09 2:13 
Questionre-instantiate ( or create new ) an object in an own method Pin
JvKsp28-Jul-09 15:30
JvKsp28-Jul-09 15:30 
AnswerRe: re-instantiate ( or create new ) an object in an own method Pin
Nagy Vilmos28-Jul-09 21:36
professionalNagy Vilmos28-Jul-09 21:36 
QuestionsetToolTipText in DefaultMutableTreeNode Pin
Kujtim Hyseni28-Jul-09 4:50
Kujtim Hyseni28-Jul-09 4:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.