ammuswar kumar

Greenhorn
+ Follow
since Aug 19, 2001
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 ammuswar kumar

out.print("<html><head>");
out.print("</head><body>");
out.print("<a href =\" <A HREF="http://localhost:8100/servlet/DateServlet1?param" TARGET=_blank rel="nofollow">http://localhost:8100/servlet/DateServlet1?param</A>; = todaysdate \">Today'sJoke \");
out.print("</body></html>");
out.close();
}
---------------------following is the errror---DateServlet2.java------------------
C:\>javac DateServlet2.java
DateServlet2.java:19: unclosed string literal
out.print("<a href =\" <A HREF="http://localhost:8100/" TARGET=_blank rel="nofollow">http://localhost:8100/</A>; <br /> date \">Today'sJoke \");
^
DateServlet2.java:20: ')' expected
out.print("</body></html>");
^
21 years ago

out.print("<html><head>");
out.print("</head><body>");
// ----is the syntax correct for ---i mean this i how u write it in servlet program------
out.print("
Todays content");
out.print("</body></html>");
out.close();
}
21 years ago
hi jamie u have been kind enought to show me the correct path
i sincerely thank u
i wonder if u know java and servlets cos i have a code which u can see and correct it i having problem in the dates there
i am sending in the code
--------------------------------------------
see my table (title) in seq server database is :
id tdate (datetime-datatype) title
1 22/08/2001 svsdfdfj asdfjefke
2 23/08/2001 ddadkjdkdfj sddeD
.. ............... ...........................
20 10/09/2001 dfdfjskjasdk isdfjdfj
now when i say select * from title;
result
id tdate title
1 2001-08-22 00:00:00.000 xcxcdcj adafvsdsdf
now my requirement
clicking on todays content link i should get todays information(ex. if today is 22/08/2001 i should get the content of 22/08/2001)
how do u do this
using date a = new date(); stores a format whiich is not compatible with tdate
so select * from title where tdate = a; ------error
please correct this and check the code also ....cos u know i am in probabtion period so i will not get a second chance
once confirmed i will not bother u

import java.util.Date;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DisplayServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
Date todaysdate = new Date();
out.print("<html><head>");
out.print("</head><body>");
// -----------------------------------------is the syntax correct for ---i mean this i how u write it in servlet program------
out.print("
Todays content");
//out.print("<form action=\"");<br /> //out.print( req.getRequestURI() );<br /> //out.print("\" method=\"post\">");
//out.print("<input type=\"submit\" ");<br /> //out.print("value=\" \"> ");
//out.print("Display Records</form>");
out.print("</body></html>");
out.close();
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String a = req.getParameter("param");
out.print("<html><head>");
out.print("</head><body>");
out.print("<code><pre>");

Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc dbc dbc_exmp,userid,pwd");
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM title where tdate='a'");
while(rs.next()) {
out.print(rs.getObject(1).toString());
out.print("\t");
out.print(rs.getObject(2).toString());
out.print("\t\t");
out.print(rs.getObject(3).toString());
out.print("\n");
}

} catch (SQLException e) {
throw new
ServletException("Servlet Could not display records.", e);
} catch (ClassNotFoundException e) {
throw new
ServletException("JDBC Driver not found.", e);
} finally {
try {
if(rs != null) {
rs.close();
rs = null;
}
if(stmt != null) {
stmt.close();
stmt = null;
}
if(con != null) {
con.close();
con = null;
}
} catch (SQLException e) {}
}
out.print("</pre></code>");

out.print("</body></html>");
out.close();
}
}
this is my code---------------------------
now my problem

i have a table in SQL-SERVER named as title
this table has three fields
1.id
2.tdate----this is of the type datetime
3.content
i am using JRUN 3.0
i want to make a java servlet in which u have a text link
Date todaysdate = new Date();
todays content;
In the servlet :
i am accepting this parameter as
String a = request.getParameter("param");

i will the database connecion---------------------
then
'
select * from title where tdate = 'a';

-----------but this not showing any result
error;
there is something wrong here in he compatitbility of 'a' with tdate
hi mocca
u are damn right whatever u said abbt me but the fact of the matter is i have just joined a company where i am seeking desparate job , i am on probabtion period so this task has been given to me to be accomplished but i have scarce knowledge abt java and servlets so i may loose my job also if i dont perform my job so i take whatever help possible from u guys ,
once i get my job somehow i will learn everything and u be credited for this.
i thank u sincerely for whatever help u have given.
i promise i will seek ur advice.
regards
amit
21 years ago
how do i set my classpath
i have c:/jdk1.4
21 years ago
import java.util.Date;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DisplayServlet extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {

res.setContentType("text/html");
PrintWriter out = res.getWriter();
Date todaysdate = new Date();
out.print("<html><head>");
out.print("</head><body>");
outprint("<a href="http://localhost:8100/servlet/DisplayServlet?param=todaysdate">Todays content</a>")
//out.print("<form action=\"");
//out.print( req.getRequestURI() );
//out.print("\" method=\"post\">");
//out.print("<input type=\"submit\" ");
//out.print("value=\" \"> ");
//out.print("Display Records</form>");

out.print("</body></html>");
out.close();
}

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {

res.setContentType("text/html");
PrintWriter out = res.getWriter();
String a = req.getParameter("param");

out.print("<html><head>");
out.print("</head><body>");
out.print("<code><pre>");




Connection con = null;
Statement stmt = null;
ResultSet rs = null;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc dbc dbc_exmp,userid,pwd");

stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM title where tdate='a'");


while(rs.next()) {
out.print(rs.getObject(1).toString());
out.print("\t");
out.print(rs.getObject(2).toString());
out.print("\t\t");
out.print(rs.getObject(3).toString());
out.print("\n");
}

} catch (SQLException e) {
throw new
ServletException("Servlet Could not display records.", e);
} catch (ClassNotFoundException e) {
throw new
ServletException("JDBC Driver not found.", e);
} finally {
try {
if(rs != null) {
rs.close();
rs = null;
}
if(stmt != null) {
stmt.close();
stmt = null;
}
if(con != null) {
con.close();
con = null;
}
} catch (SQLException e) {}
}

out.print("</pre></code>");


out.print("</body></html>");
out.close();
}
}
this is my code---------------------------
now my problem

i have a table in SQL-SERVER named as title
this table has three fields
1.id
2.tdate----this is of the type datetime
3.content
i am using JRUN 3.0
i want to make a java servlet in which u have a text link
Date todaysdate = new Date();
<a href="localhost:8100/servlet/dateservlet?param = todaysdate">todays content</a>;
In the servlet :
i am accepting this parameter as
String a = request.getParameter("param");

i will the database connecion---------------------
then
'
select * from title where tdate = 'a';

-----------but this not showing any result
error;
there is something wrong here in he compatitbility of 'a' with tdate

21 years ago
sir

i have a table in SQL-SERVER named as title
this table has three fields
1.id
2.tdate----this is of the type datetime
3.content
i am using JRUN 3.0
i want to make a java servlet in which u have a text link
Date todaysdate = new Date();
todays content;
In the servlet :
i am accepting this parameter as
String a = request.getParameter("todaysdate");

i will the database connecion---------------------
then
'
select * from title where tdate = 'a';

-----------but this not showing any result
error;
there is something wrong here in he compatitbility of 'a' with tdate
sir
i have a table in SQL-SERVER named as title
this table has three fields
1.id
2.tdate----this is of the type datetime
3.content
i am using JRUN 3.0
i want to make a java servlet in which u have a text link
Date todaysdate = new Date();
<a href="localhost:8100/servlet/dateservlet?param = todaysdate">todays content</a>;
In the servlet :
i am accepting this parameter as
String a = request.getParameter("todaysdate");

i will the database connecion---------------------
then
'
select * from title where tdate = 'a';

-----------but this not showing any result
error;
there is something wrong here in he compatitbility of 'a' with tdate
21 years ago
sir
i have a teble in a database with fields
1.id
2.tdate (dd/mm/yy)
3.title
how do i check for equality compatibility of tdate with system date)
select * from table where tdate = system date //----> some other format
is there any way to make them both compatible with each other so they could be checked for equality.(using java or java servlet)
21 years ago
sir
i have a teble in a database with fields
1.id
2.tdate (dd/mm/yy)
3.title
how do i check for equality compatibility of tdate with system date)
select * from table where tdate = system date //----> some other format
is there any way to make them both compatible with each other so they could be checked for equality.

Originally posted by mocca az:
Greetings!
I'm sorry, i see where i got you confused. Copy and paste following code and play with it a little bit. You will have to figure out how to get the date in format you need it. Check documentation for the Date class in JDK. It is under java.util.


hi mocca
u did a great job sending me the code and i really appreceate ur help ,only fix on mind left is u send the code in jsp and not in java servlets (my original poblem), do both work in the same fashion?
thanks anyways , i am obliged
regards
amit
21 years ago
please tell me how to show system date in servlet
21 years ago
sir/mam
pls tell me in java how to get system date and store it in a variable
so that i can compare this variable with the database to get the data
21 years ago
sir/mam
pls tell me in java how to get system date and store it in a variable
so that i can compare this variable with the database to get the data
21 years ago
hi kichu
thanks for the reply i tried it but the problem is even if i login and then successfully use the connector wizard then also the servlet does not run
what happens is i have to keep starting/restarting the default server
and once in every 10 tries i get my servlet running ,but if run it again it will not run .
where do u keep ur java file the compiled java file has to be kept in the WEB-INF/CLASSES directory of JRUN and tell me how did u specify the class path for javac because if and only is i keep the java file at the root directory i.e. c:\ then only the file compiles .so every time i have to cut and paste the .class file to the WEB-INF/CLASSES directory of JRUN.
please advice me
regards amit
21 years ago