Win a copy of Rust Web Development this week in the Other Languages forum!

jyotsana dang

Ranch Hand
+ Follow
since Sep 26, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jyotsana dang

Hi,
Here is a part of my code that should search for records and display the same in my jsp page. But it throws an unusual error that driver does not support this function.
<%
Connection con=null;
java.sql.PreparedStatement stmt=null;
ResultSet rs=null;
String table="";
int year=0;
String str="";
String user_login="";
String project_title="";
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:mech_iit");
table=request.getParameter("table");
System.out.println(table);
year=Integer.parseInt(request.getParameter("list_year"));
System.out.println(year);
user_login=request.getParameter("user_login");
System.out.println(user_login);
if(table.equals("publication"))
{
str="select paper_title,year from publications where user_login=? and ([year]=?)";
}
else
if(table.equals("sponsored_project"))
{
str="select project_title,year from sponsored_projects where user_login=? and ([year]=?)";
}
if(table.equals("consultancy"))
{
str="select project_title,year from consultancy_projects where user_login=? and ([year]=?)";
}
else
if(table.equals("supervised_project"))
{
str="select project_title,year from projects_supervised where user_login=? and ([year]=?)";
}
else
if(table.equals("manual"))
{
str="select title,year from manuals where user_login=? and ([year]=?)";
}
else
if(table.equals("technical_report"))
{
str="select tech_title,year from tech_reports where user_login=? and ([year]=?)";
}
stmt=con.prepareStatement(str);
stmt.setString(1,user_login);
stmt.setInt(2,year);
rs=stmt.executeQuery(str);

while(rs.next())
{
project_title=rs.getString(1);
String year1=rs.getString(2);
//tech_title=rs.getString("tech_title");
//paper_title=rs.getString("paper_title");
System.out.println(project_title);
System.out.println(year);
out.println("<html>");
out.println(" ");
out.println(" ");
out.println("<p align=center>");
out.println("<b>"+"RECORDS"+"</b>");
out.println("</p>");
out.println("<table border=1 div align=center width=80% cellpadding=2 cellspacing=2>");
out.println("<tr>");
out.println("<td>");
out.println("<div align=center>");
out.println("<b>"+"<font face=Arial>"+"Title"+"</font>"+"</b>"+"</div>");
out.println("</td>");
out.println("<td>");
out.println("<div align=center>"+"<b>"+"Year"+"</b>"+"</div>");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>");
out.println(project_title);
out.println("</td>");
out.println("<td>");
out.println(year);
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>");
out.println(project_title);
out.println("</td>");
out.println("<td>");
out.println(year);
out.println("</td>");
out.println("</tr>");
out.println("</table>");



}

}


catch(Exception ie)
{
System.out.println("jasu");
System.out.println("Exception:"+ie);
}
%>
like if i try to search for consultancy_projects for year 2001 an exception occurs that java.sql.SQLException that the driver does not support this function.
iam trying to display the records from a database..using out.print to make an html table and display them. wanted to loop through the records and paginate them. is their a way out to loop thru the records without using the getter and the setter methods of java.
thanks
17 years ago
JSP
i have 2 drop-down boxes in my html form. One contains the names of all the tables from where records have to be displayed and the other contains the year values. User selects a table from the first list like publications and an year value and is displayed records accordingly.
iam giving a request.getParameter and an if else statement to see what the user has selected.
Can anyone give me further suggestions on this?
17 years ago
JSP
i wrote a query for updation but it gives a syntax error.
rs=stmt.executeQuery("select level, project_title, student_names, co_supervisor, year from projects_supervised where project_id in("+selected_Id+")");
incorrect syntax near ')'
well, i did the following changes in my page.
String path="";
rs=stmt.executeQuery("select image from table");
path=rs.getString("image");

image is the string type column name where the path to the image is stored. images are of jpg type stored in the server.
but iam still not able to display the images in my jsp page.
Any better way of doing this?
Can anyone provide me with a code for this stuff?
thanks
[ April 21, 2004: Message edited by: jyotsana dang ]
17 years ago
JSP
now..this is strange..there is a particular table where in if i put in my login and password..the records are getting inserted..as they are..
but if another user..puts in his records..the records are getting inserted as null..what could be the problem for this..
all the records..of that person...are found to be null..
please.help, and any ways..to retrieve the original records..
thanks
got to know my error..dont know how but mistakenly..i had not specified..the jsp page specifications on top of that page..that is the page language..and all..now anyways to retrieve the data that had been inserted before..
[ April 13, 2004: Message edited by: jyotsana dang ]
hi..tkx for the reply..and iam storing urls only..
but can u elaborate further..as to how can we display then on the jsp page..

made the following changes:
stored the url of the image in the database..
and in the jsp page..defined a path variable.
string path=rs.getString("http://localhost:8080/mech_iit/images");
and a select query to retrieve the image..from the table..
and in img tag:
<img height=150 src=<%=path%>>
bt thats not solving the problem..
doesnt show in any image
[ April 07, 2004: Message edited by: jyotsana dang ]
17 years ago
JSP
hi,
iam working on my search page..when a users name is typed..his details and his snap in jpg format is shown on the next jsp page.
which is the better way to show the image in jsp, by storing the url of the image in the table or making a column with image type. iam using sql 2000 as my database.
please guide me as to how to store and retrieve the image in the jsp page..
17 years ago
JSP
iam getting a null in the next update page..
it doesnt go in the if(rs.next()) to update the record and gives null as the output.
17 years ago
JSP
this jsp page throws a number format exception when updating the records..
The first page will display the previously stored record.
<%
Connection con=null;
java.sql.Statement stmt=null;
ResultSet rs=null;
boolean y=false;
int i;
String xy=(String)session.getAttribute("y");
System.out.println("select Desg,Email_id,EPABX,Home_Page from login where user_login='"+xy+"'");
String Desg="";
String Email_id="";
String address="";
String Home_Page="";
int EPABX=0;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:mech_iit");
stmt=con.createStatement();
rs=stmt.executeQuery("select Desg,Email_id,EPABX,Home_Page from login where user_login='"+xy+"'");
if(rs.next())
{
Desg=rs.getString("Desg");
Email_id=rs.getString("Email_id");
EPABX=rs.getInt("EPABX");
Home_Page=rs.getString("Home_Page");
}
}
catch(Exception e)
{
System.out.println("exception in block"+e);
}
System.out.println("Desg="+Desg);
System.out.println("Email_id="+Email_id);
System.out.println("EPABX="+EPABX);
System.out.println("Home_Page="+Home_Page);
%>

The next page updates the records.
<%
Connection con=null;
java.sql.Statement stmt=null;
java.sql.ResultSet rs=null;
boolean x=false;
boolean y=false;
int i;
String xy=(String)session.getAttribute("y");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:mech_iit");
stmt=con.createStatement();
String Desg=request.getParameter("Desg");
String Email_id=request.getParameter("Email_id");
String Home_Page=request.getParameter("Home_Page");
int EPABX=Integer.parseInt(request.getParameter("EPABX"));
if(rs.next())
{

out.println("update login set Desg='"+Desg+"',Email_id='"+Email_id+"',Home_Page='"+Home_Page+"',EPABX="+EPABX+" where user_login='"+xy+"'");
rs=stmt.executeQuery("update login set Desg='"+Desg+"',Email_id='"+Email_id+"',Home_Page='"+Home_Page+"',EPABX="+EPABX+" where user_login='"+xy+"'");
System.out.print("Desg"+Desg);
System.out.print("Email_id"+Email_id);
System.out.print("Home_Page"+Home_Page);
System.out.print("EPABX"+EPABX);
}
}

catch(Exception e)
{
System.out.println(e);
}
%>
17 years ago
JSP
hi..
in my application iam implementing the logout jsp part like this..
<%
if (session.isNew()==true)
response.sendRedirect(response.encodeRedirectURL("index.jsp"));
%>
<%
session.invalidate();
%>
<h4> You are being Logged out </h4> <br>
<a href = "index.jsp"> Login </a><br>
<b>Session ID: </b><%= session.getId() %>
%>
but when i hit the browser's back button, iam able to see the records once again..can we disable the back button ..
and when i refresh the page..the login(index.jsp) appears again..
thanks
[ March 23, 2004: Message edited by: jyotsana dang ]
in my search part..i wanted that when the user name is found..his cv is displayed.in the browser..
i stored the cvs in tomcat..and the path to the cv in the details table of the user..
and given an href like this..
<a href ="<%="http://meiitd:8080/mech_iit/resumes"%>?user_login=<%=user_login%>"
here..as soon as i click the name ..it shows a directory listing of all the resumes..
how can i show that particular users cv..when his name is displayed in the search results page.
just wanted to explain my database..
i have 6 tables(which have information on different projects) with an identity column in each of them. The main table is login with user_login as the primary key field. The rest of the tables have user_login as the foreign key field..
iam trying to display from every table the titles of the projects and display them on the results page..
i guess will work on outer joins in the same..but if anyone has a better solution for this..please guide me..
thanks
very right!!
here is my code for updation..
there is a browse page..which has links at the end of each record..to modify..
like <a href="modify_teaching_load.jsp"?selected_Id="<%=ob.getLoad_id()%>" >Modify</a>
load_id is the identity column of my table..
and in modify page the code is like this:
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:mech_iit");
stmt=con.createStatement();
String selected_Id="";
semester=request.getParameter("semester");
course=request.getParameter("course");
course_no=request.getParameter("course_no");
course_title=request.getParameter("course_title");
selected_Id=request.getParameter("selected_Id");
if(request.getParameter("Update")!=null)// if this page is called after hiting submit button.
{
stmt.executeUpdate("update teaching_load set semester='"+semester+"',course='"+course+"',course_no='"+course_no+"',course_title='"+course_title+"'");
%>
<jsp:forward page="teaching_load_modified.jsp?RecordCount=5"/>

<%
}
//this part will be executed..if this page is not called after hiting submit.
out.println("select semester, course, course_no, course_title from teaching_load where load_id in("+selected_Id+") ");
rs=stmt.executeQuery("select semester, course, course_no, course_title from teaching_load where load_id in("+selected_Id+") ");
if(rs.next())
{
semester=rs.getString("semester");
course=rs.getString("course");
course_no=rs.getString("course_no");
course_title=rs.getString("course_title");
}
}

catch(Exception ie)
{
System.out.println("ie");
}
%>
bt on the next page..all the values are gettign displayed as null..
17 years ago
JSP