• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

Passing A Value -- HELP!

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
jmc430
Asked:
jmc430
  • 3
  • 2
  • 2
  • +2
4 Solutions
 
CEHJCommented:
>>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
 
sudhakar_koundinyaCommented:
/**

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
 
objectsCommented:
can u post your jsp.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
sunil_bandaruCommented:
<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
 
sunil_bandaruCommented:
or u can even check with no quotes at all. ie. the way shown below

<input TYPE="hidden" name="cPk" value=<%=cPk%>>
0
 
objectsCommented:
whats the value of cPK?

Have you tried:

<input TYPE="hidden" name="cPk" value="<%= java.net.URLEncoder.encode(cPk, "UTF-8") %>">
0
 
sudhakar_koundinyaCommented:
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
 
jmc430Author Commented:
Hi .. thanks for all of your help.

=)
0
 
CEHJCommented:
8-)
0
 
sudhakar_koundinyaCommented:
:-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now