Error:Type mismatch: cannot convert from Long to Long

hi friends,
I've a problem.I've a JSP that does some long converions,and its working fine when i make it run on my machine i.e
(Running Tomcat5.0),but when I deploy this file on the server which runs Tomcat 5.5.7,it throws this error:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 20 in the jsp file: /abc.jsp
Generated servlet error:
Type mismatch: cannot convert from Long to Long
Can anyone of you,tell me where i am going wrong???

Here is an example of doing it with a JavaBean... the bean looks like this:
package net.thelukes.steven;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class FormHandlerBean implements Serializable {
     private static final long serialVersionUID = 1L;
     private Date startTime = null;
     private DateFormat dateFormatter;
     public FormHandlerBean() {
          setDateFormat("yyyy-MM-dd hh:mm:ss");
     public void setStart(String strt) {
          setStartAsString(strt);
     private void setStartAsString(String strt) {
          setStartAsDate(getDate(strt));
     private void setStartAsDate(Date d) {
          startTime = d;
     private Date getDate(String s) {
          Date d = null;
               try {
                    d = dateFormatter.parse(s);
               } catch (ParseException pe) {
                    System.err.print("Error Parsing Date for "+s);
                    System.err.println(".  Using default date (right now)");
                    pe.printStackTrace(System.err);
                    d = new Date();
          return d;
     public long getStartAsLong() {
          return getStart().getTime();
     public String getStartAsString() {
          return Long.toString(getStartAsLong());
     public Date getStart() {
          return startTime;
     public void setDateFormat(String format) {
          dateFormatter = new SimpleDateFormat(format);
}You would only need to make the getStartXXX methods public that need to be accessed from the JSP. For example, if you will not need to get the Long value of the time, then you do not need to make getStartAsLong public...
The JSP looks like this:
<html>
  <head>
    <title>I got the Form</title>
  </head>
  <body>
    <h3>The Output</h3>
    <jsp:useBean class="net.thelukes.steven.FormHandlerBean" id="formHandler"/>
    <%
         formHandler.setStart(request.getParameter("start"));
    %>
    <table>
      <tr><td>Start as String</td><td><jsp:getProperty name="formHandler" property="startAsString"/></td></tr>
      <tr><td>Start as Date</td><td><jsp:getProperty name="formHandler" property="start"/></td></tr>
      <tr><td>Start as long</td><td><jsp:getProperty name="formHandler" property="startAsLong"/></td></tr>
    </table>
  </body>
</html>If this were a servlet processing the form rather than a JSP, I might throw the ParseException that might occur in getDate and catch it in the Servlet, with which I could then forward back to the form telling the user they entered mis-formatted text value... But since JSPs should be mainly display, I catch the exception internally in the Bean and assign a safe value...

Similar Messages

  • HelloClient.cpp(36) : error C2440: 'initializing' : cannot convert from 'class CORBA_WStringValue *' to '

    "HelloClient.cpp(36) : error C2440: 'initializing' : cannot convert from 'class CORBA_WStringValue *' to 'const char *'"Hi I am getting this error when I try toprint the value which I am getting fromthe RMI Implementation class.Thanks.

    What orb are you using in the client?
    LP wrote:
    "HelloClient.cpp(36) : error C2440: 'initializing' : cannot convert from 'class CORBA_WStringValue *' to 'const char *'"Hi I am getting this error when I try toprint the value which I am getting fromthe RMI Implementation class.Thanks.

  • Cannot convert from java.util.Date to java.sql.Date

    In the below code am trying to get the current date and 60 days prior date:
    Date  todayDate;
              Date  Sixtydaysprior;
              String DATE_FORMAT = "MM/dd/yy";
              DateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
             Calendar cal = Calendar.getInstance();
              todayDate = sdf.parse(sdf.format(cal.getTime()));
              cal.add(Calendar.DATE, -60);
             Sixtydaysprior = sdf.parse(sdf.format(cal.getTime()));I have imported following files:
    <%@page
         import="java.util.Calendar,
                   java.text.SimpleDateFormat,
                   java.text.ParseException,
                            java.util.*"
    %>Shows up following error msg:
    Type mismatch: cannot convert from java.util.Date to java.sql.Date
    Thanks.
    Edited by: MiltonDetroja on May 22, 2009 11:03 AM

    Shows up following error msg:
    Type mismatch: cannot convert from java.util.Date to java.sql.Date
    I don't think this exception is thrown from the portion of code you have shown. As clearly specified in exception message, you cannot cast an instance of java.util.Date to java.sql.Date. you will need to do something like this
    java.util.Date today = new java.util.Date();
    long t = today.getTime();
    java.sql.Date dt = new java.sql.Date(t);

  • Cannot convert from ImageIcon to Image

    Please tell me why I'm getting error: I have seen many example of this both in this forum and other places.
    Type mismatch: cannot convert from ImageIcon to Image[b]
    Thanks in advance
    here's my code, I m using fileupload to load my images:
    <%@ page import="java.util.List"%>
    <%@ page import="java.util.Iterator"%>
    <%@ page import="java.io.File" %>
    <%@ page import="java.io.IOException"%>
    <%@ page import="java.io.*"%>
    <%@ page import="java.awt.image.ImageFilter"%>
    <%@ page import="java.awt.Color"%>
    <%@ page import="java.awt.image.ImageProducer"%>
    <%@ page import="java.awt.image.ReplicateScaleFilter"%>
    <%@ page import="java.awt.image.FilteredImageSource"%>
    <%@ page import="javax.swing.*"%>
    <%@ page import="java.awt.image.BufferedImage"%>
    <%@ page import="java.awt.Image"%>
    <%@ page import="java.awt.Graphics"%>
    <%@ page import="java.awt.Toolkit"%>
    <%@ page import="com.sun.image.codec.jpeg.JPEGCodec"%>
    <%@ page import="com.sun.image.codec.jpeg.JPEGImageEncoder"%>
    <%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
    <%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
    <%@ page import="org.apache.commons.fileupload.*"%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
       <center><table border="2">
            <tr><td><h1>Your files  uploaded </h1></td></tr>
       <%
        //setting the target w + h
         int targetWidth=0;
        int targetHeight=0;
         //session values used to rename loaded image.
         String adID = "EM225";
         session.setAttribute("adID", adID);
         String fileName = null;
      // String imageid = request.getParameter("imgageID");
         boolean isMultipart = ServletFileUpload.isMultipartContent(request);
         if (!isMultipart) {
         } else {
            FileItemFactory factory = new DiskFileItemFactory();
            ServletFileUpload upload = new ServletFileUpload(factory);
            List items = null;
            try {
                 items = upload.parseRequest(request);
            } catch (FileUploadException e) {
                 System.out.println("Unable to load image" +  e.getMessage());
            Iterator itr = items.iterator();
            while(itr.hasNext()) {
                   FileItem item = (FileItem) itr.next();
                   if (item.isFormField()) {
                        //String name = item.getFieldName();  //This will get the field names. for eg. if u have a hidden field this line will get the hidden filed name.
                    //value = item.getString();
                        //out.println(value);
                   } else {
                 try {
                      File fullFile  = new File(item.getName());
                      fileName = fullFile.getName();
                      String id = (String)session.getAttribute("adID");
                      String newName =  id+fileName;
                      //passing renamed uploaded image.
                      Image sourceImage = new ImageIcon(Toolkit.getDefaultToolkit().getImage(newName));
                      // Calculate the target width and height
                      float scale = 50/100;
                      targetWidth = (int)(sourceImage.getWidth(null)*scale);
                      targetHeight = (int)(sourceImage.getHeight(null)*scale);
                      BufferedImage resizedImage = this.scaleImage(sourceImage,targetWidth,targetHeight);
                      ByteArrayOutputStream baos = new ByteArrayOutputStream();
                   JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(baos);
                      encoder.encode(resizedImage);
                   byte[] b = baos.toByteArray();
                     // File tosave = new File(getServletContext().getRealPath("/"),resizedImage);
                     // item.write(tosave);
                 } catch (Exception e) {
                      System.out.println("Unable to save the image" + e.getMessage());
       %>
       <%!
       private BufferedImage scaleImage(Image sourceImage, int width, int height){
            ImageFilter filter = new ReplicateScaleFilter(width,height);
            ImageProducer producer = new FilteredImageSource
            (sourceImage.getSource(),filter);
            Image resizedImage = Toolkit.getDefaultToolkit().createImage(producer);
            return this.toBufferedImage(resizedImage);
        private BufferedImage toBufferedImage(Image image){
            image = new ImageIcon(image).getImage();
            BufferedImage bufferedImage = new BufferedImage(image.getWidth(null),image.getHeight(null),BufferedImage.TYPE_INT_RGB);
            Graphics g = bufferedImage.createGraphics();
            g.setColor(Color.white);
            g.fillRect(0,0,image.getWidth(null),image.getHeight(null));
            g.drawImage(image,0,0,null);
            g.dispose();
            return bufferedImage;
       %>
        </table>
       </center>
        </table>
       </center>

    Hello. So, it's difficult to say, but the following line is probably the cause of the problem.:
    Image sourceImage = new ImageIcon(Toolkit.getDefaultToolkit().getImage(newName));Basically, you are making an ImageIcon by passing an image, but perhaps you can just replace the line with this:
    Image sourceImage = Toolkit.getDefaultToolkit().getImage(newName);I use ImageIcon when reading from files, such as:
    BufferedImage image = ImageIO.read(file);
    Icon icon = new ImageIcon(image);However, if you already have an Image, I don't see why you just can't just use the Image reference. Perhaps someone more wise will have a more concise answer. Good luck.

  • Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 3 (NumberOfMultipleMatches).

    Hi,
    I have a file where fields are wrapped with ".
    =========== file sample
    "asdsa","asdsadasdas","1123"
    "asdsa","asdsadasdas","1123"
    "asdsa","asdsadasdas","1123"
    "asdsa","asdsadasdas","1123"
    ==========
    I am having a .net method to remove the wrap characters and write out a file without wrap characters.
    ======================
    asdsa,asdsadasdas,1123
    asdsa,asdsadasdas,1123
    asdsa,asdsadasdas,1123
    asdsa,asdsadasdas,1123
    ======================
    the .net code is here.
    ========================================
    public static string RemoveCharacter(string sFileName, char cRemoveChar)
                object objLock = new object();
                //VirtualStream objInputStream = null;
                //VirtualStream objOutStream = null;
                FileStream objInputFile = null, objOutFile = null;
                lock(objLock)
                    try
                        objInputFile = new FileStream(sFileName, FileMode.Open);
                        //objInputStream = new VirtualStream(objInputFile);
                        objOutFile = new FileStream(sFileName.Substring(0, sFileName.LastIndexOf('\\')) + "\\" + Guid.NewGuid().ToString(), FileMode.Create);
                        //objOutStream = new VirtualStream(objOutFile);
                        int nByteRead;
                        while ((nByteRead = objInputFile.ReadByte()) != -1)
                            if (nByteRead != (int)cRemoveChar)
                                objOutFile.WriteByte((byte)nByteRead);
                    finally
                        objInputFile.Close();
                        objOutFile.Close();
                    return sFileName.Substring(0, sFileName.LastIndexOf('\\')) + "\\" + Guid.NewGuid().ToString();
    ==================================
    however when I run the bulk load utility I get the error 
    =======================================
    Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 3 (NumberOfMultipleMatches).
    ==========================================
    the bulk insert statement is as follows
    =========================================
     BULK INSERT Temp  
     FROM '<file name>' WITH  
      FIELDTERMINATOR = ','  
      , KEEPNULLS  
    ==========================================
    Does anybody know what is happening and what needs to be done ?
    PLEASE HELP
    Thanks in advance 
    Vikram

    To load that file with BULK INSERT, use this format file:
    9.0
    4
    1 SQLCHAR 0 0 "\""      0 ""    ""
    2 SQLCHAR 0 0 "\",\""   1 col1  Latin1_General_CI_AS
    3 SQLCHAR 0 0 "\",\""   2 col2  Latin1_General_CI_AS
    4 SQLCHAR 0 0 "\"\r\n"  3 col3  Latin1_General_CI_AS
    Note that the format file defines four fields while the fileonly seems to have three. The format file defines an empty field before the first quote.
    Or, since you already have a .NET program, use a stored procedure with table-valued parameter instead. I have an example of how to do this here:
    http://www.sommarskog.se/arrays-in-sql-2008.html
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Error type mismatch unparseable number

    we are upgrading to crystal 2008 and i am running my report thru info view using activex viewer  - i have some parameters that i check set to null values when i do this i get the following
    error
    error type mismatch unparseable number
    this report calls a store procedure
    has anyone seen this error

    Hi Dilia,
    I'm not sure if I understand you correct. You are upgarding to CR2008 but running your reports through infoview active X viewer. Do you mean you created your reports in CR2008 and exported them to your BOE XIR3 enterprise system and you face the problem there?
    Coudl you clarify this please and let me know which BOE version you use?
    Re. the stored procedure....
    If you got a SP with IN parameters (see example below) please make sure you handle actually parameters with NULL values in your SP.
    Create procedure test (IN Name VARCHAR(30))
    P1:BEGIN
         DECLARE CURSOR ....
         IF (NAME IS NULL) THEN
             set dynstatement = 'select * from testtable';

  • Cannot convert from IPrivate{cn}view.I{cn}Element to IPublicTabComp.IPeople

    Hi,
    I have 2 context node Person and People in a view context and context node People in component controller's context ,now i want to create new People element in the implementation of view
    so when i had written code below in eventhandler method in view implementation:
    IPeopleElement newPerson = wdContext.nodePeople().createPeopleElement();
    it gives me an error :
    Cannot convert from IPrivateview.IElement to IPublicTabComp.IPeopleElement
    Any help will be appreciated.
    Thanks,
    Rashmi.

    Hi,
    i hope you mapped the component controller context "People "to view .
    then to create a element do like this,
    IPrivate<View Nmae>View.IPeopleNode pnode= wdContext.nodePeople().createPeopleElement();
    Regards,
    ramesh

  • Convert from String to Long

    Hello Frineds I want to convert from String to Long.
    My String is like str="600 700 250 300" and I want to convert it to long and
    get the total value in to the long variable.like the total of str in long varible should be 1850.
    Thank You
    Nilesh Vasani

    Maybe this would work?
    StringTokenizer st = new StringTokenizer(yourString, " ");
    long l = 0;
    while(st.hasMoreTokens()) {
        l += Long.parseLong(st.nextToken()).longValue();
    }

  • Intermittant GPIB Errors "type mismatch"

    The VB6 application I'm writing to control an Anritsu MP1570A Sonet Analyzer is now working moderately well, but I intermittently get the GPIB error,
    "Unable to talk to GPIB device.||Type mismatch."
    I find that this error does not occur if the program is single stepped. I have tried adding delays after each GPIB command and have played around with the duration. Delays seem to improve the situation but not entirely and not consistently. I'm not certain, but it seems like the problem may be less pronounced when the application is running standalone, i.e., not in the development environment. NI Spy reports no errors, by the way.
    Has anyone seen anything similar or have an idea what the fix might be?
    Thanks to all
    in advance,
    JG"

    Hi Jerry,
    I don't know of a specific reason why this may happen..but the first step would be to try and narrow this down...
    Do you have any casts in your code ?
    Especially from string to double? (from data you are getting back perhaps ?)
    Its possible that if there is a timing issue, then sometimes you may get invalid , or unexpected data back, so if you have a cast such as dblValue = Cdbl(strText) * 2 it may work most of the times, but fail, if strText is not a number in the unexpected case...
    The other case could be that, it is a Gpib Write or a Gpib Command thats failing with the type mismatch error(The command itself will not take place if there is a type mismatch error - so NI-Spy will look fine...). This could be true in the case, where data you send out is
    not a string literal, and something that you calculate in your code..
    The Read should always work, since it returns a variant..
    So those are two places you could look at for potential problems...i.e. (1) the GPIB Writes,especially those where the command is not a literal string and (2) any casts, or a combination of the two...
    Hope this helps some...
    Nandan Dharwadker
    Staff Software Engineer
    Measurement Studio Hardware Team

  • After updating I ended up with 4 icons on my desktop - I cannot delete any of them. The error message reads; "Cannot read from the source file or disk".

    I updated from the original version to 6.0.1 and when I re-started FF there were 4 icons on my desktop. I managed to delete one of them, but I cannot delete the other two - to leave me with just one.
    I get the error message of "Cannot delete file: Cannot read from the source fie or disk".

    Here's the meaning of the error that you received.
    "An error has occurred. ERROR :10-FC06-0002" -- may be caused by damaged recovery media or faulty hard drive"
    Possible that the problem is on the recovery also.
    Hope this helps.

  • OEM error " Type Mismatch "

    Hi ,
    I have OEM v1.6 on Oracle 8.0.5 on NT. While creating the job,
    when I hit the schedule tab, I get the following eror message
    " Type Mismatch " ( No error number )
    How to avoid this ? Is there any thing that needs to be set up
    to avoid this error messgae.
    I configured all the files (
    tnsnames.ora,listner.ora,sqlnet.ora,snmp_ro.ora,snmp_rw.ora,servi
    ces.ora ) correctly.
    Also there is no proper documentation on this error.
    Has any one ever got this problem . Please let me know, if you
    have a solution.
    Thanks
    Chandra Kapireddy
    null

    You need to download the latest patch. Sorry, do not have
    the I.P. address handy. However, oracle support will
    gladly give you the I.P. address.
    Chandra Kapireddy (guest) wrote:
    : Hi ,
    : I have OEM v1.6 on Oracle 8.0.5 on NT. While creating the
    job,
    : when I hit the schedule tab, I get the following eror message
    : " Type Mismatch " ( No error number )
    : How to avoid this ? Is there any thing that needs to be set up
    : to avoid this error messgae.
    : I configured all the files (
    tnsnames.ora,listner.ora,sqlnet.ora,snmp_ro.ora,snmp_rw.ora,servi
    : ces.ora ) correctly.
    : Also there is no proper documentation on this error.
    : Has any one ever got this problem . Please let me know, if you
    : have a solution.
    : Thanks
    : Chandra Kapireddy
    null

  • Cannot convert from PDF to word doc.....

    I am not able to access PDF files on my desktop to then convert.

    Hi Dan,
    What happens when you try to access the PDF files? Do you get an error message? Are you converting from within Adobe Reader, or via the ExportPDF web interface?
    Are you able to log in directly to https://cloud.acrobat.com/exportpdf and convert your files from there?
    Best,
    Sara

  • Order type selection when converting from planned order to prod order

    Hello friends,
    I have one doubt.That when i am converting the planned order to the production order than from which default settings it takes the order type.
    As we can maintain the default order type in OPPQ , under conversion and in production scheduling profile also we maintain order type for make to stock, make to order, etc.
    So my question is to which setting the system gives the priority.
    Or they both are for different purpose.
    Thanking you guys in advance.

    Hi ,
       You can maintain the order type for conversion of planned order to production order in the T Code OPPE.
    Hope it will be clear.
    Regards,

  • Type reflowing when converting from CS2 to CS3

    We have just converted a lot of our machines over to CS3 but have noticed that some of the type is reflowing differently to our files in CS2, has anyone else come across this.
    I have just noticed that it is the kerning that is causing the problem, kerning is set to Auto in CS2 which has given me a value of 0 between two of the characters but in CS3 the value is now -150 (auto), font i am using is Guia Script Pro which is opentype.

    Hi ,
       You can maintain the order type for conversion of planned order to production order in the T Code OPPE.
    Hope it will be clear.
    Regards,

  • I cannot convert from Indesign CS7 to CS6

    Is there a way of converting InDesign CS7 files to CS6 format?

    THe files need to be saved as CS6 or IDML from within CC (CS7). There is no other way .
    Mylenium

Maybe you are looking for

  • How do i lock my pdf fillable form file

    Thank you in advance for any help. I have two questions: 1)  How do I save my fill-able form pdf file as a NON fill-able form so that the saved version cannot be changed?  I have Adobe Acrobat Pro XI for the MAC 2)  How do I add a page to my pdf file

  • How not to escape characters in 3.1

    Hello In Apex 2.0 i used to store html text in an item; if i used it in an html region or in a label it worked fine, i mean it showed the formatted text. In Apex 3.0, it shows the full html text as if i used escape special characters but i want it ht

  • Putting music on your z2

    hey i try to put music files on my z2 and when i play it on the phone every song is very glitches and always cuts in and out  any help ?

  • Import options in InDesign CS2 using javascript???

    Hi i need to place an .eps or .ai files in InDesign CS2 document. While choosing "Import Options" while placing "Place PDF" dialog will be opened in which "Crop To" option will be there which has "Art" option.. I need to use this using Javascript...

  • Authorization to delete

    Using transaction PU00 giving the user authorization to delete an employee. I want to permit the user only to delete the employee. I don’t want to give a permission to read or write or update. Only delete. How can I do it