• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

converting client validation (JavaScript) to server side validation

 
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are converting client side validation of Catalog Unit Price, SBC Cost, Discount Percentage, margin percentage to Server Side Validation, but we are facing the following error.

If we add input parameter as "/catlevels.do?method=displayCart´┐Ż same as path="/catlevels", it loops through the program infinitely and it crashes the JVM. Are you able to figure out? Please advice us so that we can deliver it by tomorrow.


DEBUG com.sbc.dcomm.ui.utility.DcRequestProcessor - User 'sb6528' userId: 52 has role 'buyer(i)', granting access

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - Inside validate :

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - editableField : textDiscountPct

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - array length : 6

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - tempValue : www

DEBUG com.sbc.dcomm.ui.utility.DcRequestProcessor - User 'sb6528' userId: 52 has role 'buyer(i)', granting access

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - Inside validate :

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - editableField : textDiscountPct

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - array length : 6

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - tempValue : www

DEBUG com.sbc.dcomm.ui.utility.DcRequestProcessor - User 'sb6528' userId: 52 has role 'buyer(i)', granting access

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - Inside validate :

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - editableField : textDiscountPct

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - array length : 6

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - tempValue : www

DEBUG com.sbc.dcomm.ui.utility.DcRequestProcessor - User 'sb6528' userId: 52 has role 'buyer(i)', granting access

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - Inside validate :

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - editableField : textDiscountPct

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - array length : 6

DEBUG com.sbc.dcomm.ui.pa.forms.PAActionForm - tempValue : www

DEBUG com.sbc.dcomm.ui.utility.DcRequestProcessor - User 'sb6528' userId: 52 has role 'buyer(i)', granting access

JVMDG217: Dump Handler is Processing a Signal - Please Wait.

JVMDG303: JVM Requesting Java core file

JVMDG304: Java core file written to d:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\javacore.20050623.191812.268.txt

JVMDG215: Dump Handler has Processed Exception Signal 11.



If we redirect the error messages to testerror.jsp inlieu of "/catlevels.do?method=displayCart´┐Ż, it is working fine.

We have used the same logic which used for Trade-In and vendor Discount, both are working fine.





struts-config-pa.xml:

This code gives us error

<action path="/catlevels"

type="com.sbc.dcomm.ui.pa.actions.PAAction"

name="pAActionForm"

scope="request"

input"/catlevels.do?method=displayCart"

parameter="method"

roles="buyer(i),admin(i),org_admin(i)">

<forward name="success" path="/pa/paData.jsp"/>

</action>





This works fine



<action path="/catlevels"

type="com.sbc.dcomm.ui.pa.actions.PAAction"

name="pAActionForm"

scope="request"

input="/testerror.jsp"

parameter="method"

roles="buyer(i),admin(i),org_admin(i)">

<forward name="success" path="/pa/paData.jsp"/>

</action>


PAActionForm extends ActionForm


private static final Category log = Category.getInstance(PAActionForm.class);

public ActionErrors validate(ActionMapping mapping, javax.servlet.http.HttpServletRequest request)

{



log.debug("Inside validate :");

ActionErrors errors=new ActionErrors();



try

{



String editableField = getEditableField();

log.debug("editableField : " + editableField);

String[] array = request.getParameterValues(editableField);

if (array != null) {

log.debug("array length : " + array.length);

for (int i = 0; i < array.length; i++)

{



String tempValue = array[i];

log.debug("tempValue : " + tempValue);

if(tempValue.equals("") || tempValue == null ||tempValue.length()==0 ||tempValue.equals(" ")){

{

log.debug("Unit Price : " + tempValue);

errors.add("Unit Price",new org.apache.struts.action.ActionError("Please enter value."));

}

}

double tempVal=Double.parseDouble(tempValue);

if(tempVal<=0)

errors.add("Unit Price",new org.apache.struts.action.ActionError("pricing.GreaterThanZero"));

if(tempVal>100)

errors.add("Unit Price",new org.apache.struts.action.ActionError("pricing.LessThanHundred"));

}

}

}

catch(NullPointerException ne)

{

}

catch(NumberFormatException e){

errors.add("Unit Price ",new org.apache.struts.action.ActionError("pa.numeric"));

}

return errors;

}




:roll: :roll:

Could you please help me out ?
 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public ActionErrors validate method is being called infinetly and that might be one of the reasons ,it crashes JVM.

How can I solve this bug?
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

public ActionErrors validate method is being called infinetly and that might be one of the reasons ,it crashes JVM



I agree. I am no Struts expert, but I believe your are throwing a NullPointerException somewhere in your code. Thus the request will be forward to the value you have set in the "input" element:

Therefore sending you back to the same program:

that generated the error in the first place. Therefore sending it in a loop.
 
reply
    Bookmark Topic Watch Topic
  • New Topic