deepalihanand 0 Newbie Poster

Did you tried lastIndexOf() and deleteCharAt() of StringBuffer?

Try something like this :

int lastComma = replacement.lastIndexOf(",");
replacement.deleteCharAt(lastComma) ;

For more info, Go through this http://java.sun.com/javase/6/docs/api/java/lang/StringBuffer.html

Hope this helps!

deepalihanand 0 Newbie Poster

I forgot to mention in my earlier post that getOutputStream() should not be used in JSP.

Use only servlets via JSP. So, retrieveing .gif, .jpeg, .xls, .pdf, etc...should be done through servlet and never from JSP

deepalihanand 0 Newbie Poster
deepalihanand 0 Newbie Poster

Hello,

Use RequestDispatcher() and forward(), instead of sendRedirect().

Forwarding is not so very different from request redirection (Servlet Request.sendRedirect()). However, forwarding has an advantage—the request information (parameters and attributes) are preserved.

Hope it helps.

deepalihanand 0 Newbie Poster

when i am using the code to convert string to sql.Date

DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
Date d = df.parse(leavefrom);
String dfrom=df.format(d);

java.sql.Date dd = new java.sql.Date(d.getTime());

Date dt = df.parse(until);
String dto=df.format(dt);

java.sql.Date ddt = new java.sql.Date(dt.getTime());

I am facing the error given below because of the array so how should i code to convert it into sql.Date when the string[] is to be converted to sql.Date.Pls suggest me.
Thanks in advance.

Error: 500
Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile class for JSPC:\j2sdkee1.2.1\repository\shiju-f70efc8fa\web\_0005cupdate_0002ejspupdate_jsp_11.java:184: Incompatible type for method. Can't convert java.lang.String[] to java.lang.String.
Date d = df.parse(leavefrom);
^
C:\j2sdkee1.2.1\repository\shiju-f70efc8fa\web\_0005cupdate_0002ejspupdate_jsp_11.java:189: Incompatible type for method. Can't convert java.lang.String[] to java.lang.String.
Date dt = df.parse(until);
^
C:\j2sdkee1.2.1\repository\shiju-f70efc8fa\web\_0005cupdate_0002ejspupdate_jsp_11.java:201: [] can only be applied to arrays. It can't be applied to java.sql.Date.
ps.setDate(1,dd[counter]);
^
C:\j2sdkee1.2.1\repository\shiju-f70efc8fa\web\_0005cupdate_0002ejspupdate_jsp_11.java:202: [] can only be applied to arrays. It can't be applied to java.sql.Date.
ps.setDate(2,ddt[counter]);
^
4 errors

These errors help to understand the problem -

For 1st Error - use Date d = df.parse(leavefrom[counter]);
For 2nd error - use Date dt = df.parse(until[counter]);

and then in last 2 errors why are you using ps.setDate(1,dd[counter])
instead it should be ps.setDate(1,dd);

deepalihanand 0 Newbie Poster

If the column in the DB is declared to be type Date, the format is irrelevant. Because the column will contain Date not a Varchar. The data int the column doesn't have a format nor it needs one because it is type data. You can put data inside it in any way you want as long it is type Date.

Check for these sql functions:
to_date(), to_char()

According to me, MS-Access database require format before entering date field for more accuracy. Correct me, if I am wrong. This forum helps me in learning.
Thanks

deepalihanand 0 Newbie Poster

Hello,

Just try to use trim() for id and pin i.e when retrieving from database and then compare with loginid and loginpin.

I hope it solves the problem.

deepalihanand 0 Newbie Poster

Hello,

Just remember that SimpleDateFormat.parse(String source) returns java.util.Date

and PreparedStatement.setDate(int i, Date d) takes java.sql.Date .
So, while passing the date parameter here, casting is required.

2nd thing keep in mind that while converting a String to Date - take care of format according to your database. Some may take as mm/dd/yyyy or dd/mm/yyyy. So, accordingly pass the parameter to SimpleDateFormat constructor.

Hope it solves your problem. And do let me know.

deepalihanand 0 Newbie Poster

Have you inserted username and password in Service.connect()?

deepalihanand 0 Newbie Poster

According to me - try this :

HttpSession session = request.getSession();

MailUserBean nameBean =
      (MailUserBean)session.getAttribute("nameBean");

    if (nameBean == null) {
      ...Your steps //String firstName = request.getParameter("firstName");
      //String lastName = request.getParameter("lastName");
      //nameBean = new MailUserBean(firstName, lastName);
      session.setAttribute("nameBean", nameBean);
    }

Do let me know, if it works. If it does not do send the complete code.

Thanks