?
Solved

Passing A Value -- HELP!

Posted on 2004-10-06
10
Medium Priority
?
181 Views
Last Modified: 2010-03-31
Greetings!

I'm getting the following error:

Error:         java.lang.NumberFormatException: For input string: "<%cPk%>"
Reason:        For input string: "<%cPk%>"

Basically I aimed to pass a hidden value from one application to another, in order to hide the URL location from users' browsers.

I used a "POST" form instead of a "GET", and used the correct input tag - <input TYPE="hidden" name="cPk" value="<%=cPk%>">

However, I suspect that the value of cPk, a primary key, is not being correctly passed  in the proper format .. although I made the types consistent in my code (and when I hardcoded a number value, I know conceptually this thing should actually work):

Here is the relevant code from the class in the first application:

=========================================================================================
   protected Double cPk;

   public Double getCPk() {
        return cPk;
    }

    public void setCPk(String getCertificateUrl) {
        cPk = new Double(getCertificateUrl);
    }
    public String getCertificateUrl() {
        String cPk = certification.certificationPk().toString();
        //String url = "https://hostname/etc/WebObjects/PDFGenerator.woa/wa/viewReport?cPk=" + cPk;
        //String url = certification.certificationPk().toString();
        return cPk;
    }
========================================================================================
   and here is the relevant code in the second application:

========================================================================================
protected Double cPk;

private NSArray lookupCertification() {      
        // Lookup Certification via cPk
        return fetchSearch("getCertificationPk", "Certification", "cPk", getCPk(), this.session().defaultEditingContext());
    }
   
    public Double getCPk() {
        return cPk;      
    }

    public void setCPk(String newCPk) {
        cPk = new Double(newCPk);
    }
========================================================================================
and here is some more relevant code from another class:
========================================================================================
public void takeFormValues(NSDictionary value) {
        java.util.Enumeration e = getValueList().objectEnumerator();

        while (e.hasMoreElements()) {
            String key = (String)e.nextElement();

            Object obj = context().request().formValueForKey(key);
            if (obj != null) {
                takeValueForKey(obj, key);
            }
        }
    }
========================================================================================

I am ripping what little is left of my hair out ... I suspect the issue is trivial but the cause of the error is beyond me.

Any advice and or guidance would be greatly appreciated!

Best regards,
nearly hairless jamie
0
Comment
Question by:jmc430
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 500 total points
ID: 12240900
>>String url = "https://hostname/etc/WebObjects/PDFGenerator.woa/wa/viewReport?cPk=" + cPk;

should probably be

String url = "https://hostname/etc/WebObjects/PDFGenerator.woa/wa/viewReport?cPk=" + java.net.URLEncoder.encode(cPk, "UTF-8");

and use the corresponding decoder on the other side

If that doesn't work, please post value of cPk
0
 
LVL 14

Assisted Solution

by:sudhakar_koundinya
sudhakar_koundinya earned 500 total points
ID: 12241252
/**

protected Double cPk;

   public Double getCPk() {
        return cPk;
    }

    public void setCPk(String getCertificateUrl) {
        cPk = new Double(getCertificateUrl);
    }
    public String getCertificateUrl() {
        String cPk = certification.certificationPk().toString();
        //String url = "https://hostname/etc/WebObjects/PDFGenerator.woa/wa/viewReport?cPk=" + cPk;
        //String url = certification.certificationPk().toString();
        return cPk;
    }**/

You define cPk as Double at class level and in getCertificateUrl method u r using it as String

Check if this gives problem to u

Regards

0
 
LVL 92

Assisted Solution

by:objects
objects earned 500 total points
ID: 12244059
can u post your jsp.
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 1

Accepted Solution

by:
sunil_bandaru earned 500 total points
ID: 12247195
<input TYPE="hidden" name="cPk" value="<%=cPk%>">

plz use single quotes around <%=cPk%> in the jsp as shown below and try running the application:

<input TYPE="hidden" name="cPk" value='<%=cPk%>'>
0
 
LVL 1

Expert Comment

by:sunil_bandaru
ID: 12247215
or u can even check with no quotes at all. ie. the way shown below

<input TYPE="hidden" name="cPk" value=<%=cPk%>>
0
 
LVL 92

Expert Comment

by:objects
ID: 12254553
whats the value of cPK?

Have you tried:

<input TYPE="hidden" name="cPk" value="<%= java.net.URLEncoder.encode(cPk, "UTF-8") %>">
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12256139
Hello  jmc430,

With out your responses it is difficult to analyse your problem. Let us know if any of the suggestions helped you

Best Regards
Sudhakar  
0
 

Author Comment

by:jmc430
ID: 12311897
Hi .. thanks for all of your help.

=)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12311947
8-)
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12312782
:-)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question