• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to get the output in required format

 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i had a doubt that the output should come like 'F,10:'..but i m getting as 'F,10'..i tried so many times..i m not getting can any one suggest me where the code gets wrong...here i m sending jsp code,javascript code and servlet code..can anyone check it..i m waiting for the reply...its urgent.

login.jsp



login.js



login.java



Thanks and waiting for the reply,
madhu.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having different input types (like text and checkbox) with the same name is a bug waiting to happen. Why don't they have distinctive names?

Also, the servlet code doesn't make sense - both branches of the if statement do the same thing (although it probably doesn't matter, because the "if" branch will never be executed, since "balrdysStr" is never null).
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'F,10:'..but i m getting as 'F,10'

you need : at end ??
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
yes i need
:
at the end of
F,10
..can you help me out regarding this matter...

Thanks in advance,
madhu
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



you can append it ":" naa after reading the value in bean .

value = value+":" ;

getting or not ?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see no colon in the code you posted; where do you expect it to come from?
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Madhu,
You are retieving values
like this ok ?

String[] balrdys = request.getParameterValues("balrdys");

so iterate this loop

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

String days=(balrdys[i]).append(":");
}

check this out let me know >
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i had done it previously..i m getting wrong output..not the required out..here is my output code..

output:


login.jsp



login.java



i need to get the output as



can you provide me the solution for this...waiting for the reply..
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya where is your cubicle

Added check

String[] balrdys = request.getParameterValues("balrdys");
String balrdysStr = "";
for (int i = 0; i < balrdys.length; i++) {
if (balrdysStr == null) {
balrdysStr += balrdys[i];
} else {
balrdysStr += balrdys[i];
//added by Ravi
if(i<balrdys.length-1)
{
balrdysStr = balrdysStr +":";
}
}
}

check this out >
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again:
Having different input types (like text and checkbox) with the same name is a bug waiting to happen. Why don't they have distinctive names?

Also, the servlet code doesn't make sense - the "if" branch will never be executed, since "balrdysStr" is never null.
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i don't this so , she is expecting output as F,10: how will she get desired output with out appending ":" at end of value
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi good morning,
i tried what you had given..i m getting same wrong output not the correct output...down i m giving the output..is there any method to get the correct output..i tried so many ways unable to get it...



thanks,
madhu
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning.

I'd like to point out that :
1. You should read carefully what Ulf is telling you.
2. You need to describe your needs clearly, what you are expecting, and how you are expecting it to happen. I think it's useless to throw you semi-colons without understanding your needs. I still have no clue about that semi-colon you're dying to see in the output. For example:
"I click the checkbox whose value is "F," and enter "10" in the textbox. After submitting, I expect that the logic which retrieves the ""balrdys" values will result in "F,10:". I have to append the selected checkbox value, the entered text, and finally append a semi-colon to it". Something like that.

So... what do you really want to achieve ?
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what you had replied is correct...if i click checkbox and if i enter the value in textbox both should be appended after submit button and the answer what i need is 'F,10:'
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I'm still guessing :
If you select "F,", you want the Fresh Activation text appended to it ? -> "F,10:"
If you select "A,", you want the Auto-Renewal text appended to it ? -> "A,20:"
If you select both "F," and "A," -> "F,10,A,20:"
Is this something like this ? What about the "NO" checkbox ?
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI ........ its as simple as dat ...Madhu why dont you try what i am saying ...........
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"dat"?
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its short hand notation for that.
while sending text from mobile we use that kind of short cuts ;)
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Christope,

what you are guessing is rite...



i need the output like that..

 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ravindra,
good morning...i tried what you suggested i m not getting the correct output..here with i m sending the code...

 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what are you getting now ?
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i m getting the output as

<LOW_DAYS>F,:10:</LOW_DAYS>
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Madhu,

I trid what code you have given ,ok

you have 3 checkboxes , one with value No and other twos having input type as text,
so you are geeting 3 values two in nuber of days and one as No

so better you modify the code like this


<td><input type="checkbox" name="chk_Fbalrdys" value="F,"id="chkA">Fresh Activation <input type="text" name="Fbalrdys" size="1" id="txtA"/>

<input type="checkbox" name="Chk_Abalrdys" value="A,">Auto-Renewal <input type="text" name="Abalrdys" size="1">

<input type="checkbox" name="Chk_Nbalrdys" value="NO">No



and in bean read values like this


tring _Fdays = request.getParameter("Fbalrdys");
String _Adays request.getParameter("Abalrdys");

if(_Fdays!=null )
{
_Fdays=_Fdays.append(":")
}

if(_Adays! null)

{
_Adays=_Adays.append(":")
}



hope this will work ....

Are you from which company ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Ulf said (please read his posts!!), giving the same name to all your components is not a good idea. Looping through the values returned by getParameterValues will give you unpredictable results. Why don't you give each component its own name, and get each values one by one ? You'll easily get the result you want by doing so.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ravindra,
i tried its not getting... the output i got is

<LOW_DAYS>10::</LOW_DAYS>
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Slight change

i have not used checkbox values that is F,


so in bean use

tring _Fdays = request.getParameter("Fbalrdys");
String _Adays request.getParameter("Abalrdys");

if(_Fdays!=null )
{
_Fdays= "F,"+_Fdays.append(":")
}

if(_Adays! null)

{
_Adays="A,"+_Adays.append(":")
}

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of trying to give a complete solution, I think it would be better to leave madhuri try to understand where the problem is, and let him update his code after reading our recommendations.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ravindra,
i got it...thanks for your support...my doubt was not still clarified...i m developing web-application...using jsp page i need to develop XML file...i created..i used what you suggested in my code...the problem is i m getting 2 times the element..i.e.,

<LOW_DAYS>F,10::</LOW_DAYS>
<LOW_DAYS>A,10:::</LOW_DAYS>

but i need is <LOW_DAYS>F,10:A,11:</LOW_DAYS>

how can i get that..
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will you please update me with the code you are using to create xml
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
login.js




login.java

 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I havent worked on xml

but still modified the code combine A days and F days under Low Days tag ...

Element balrdysElement = doc.createElement("DAYS");
subchild.appendChild(balrdysElement);
Element balrdysElement1 = doc.createElement("LOW_DAYS")
Text balrdysElementText = doc.createTextNode(_Fdays+_Adays);
balrdysElement1.appendChild(balrdysElementText);

;
subchild.appendChild(balrdysElement1);
Text balrdysElementText1 = doc.createTextNode(_Adays);
balrdysElement1.appendChild(balrdysElementText1);
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thanks i'll check it..do you have any idea regarding javascript...
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
_/\_ Yes ...go ahead ...you can post it in a new thread.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the site you had given is not opening....i had created XML file...my doubt is how to do DML operations for XML file...for that i m using jsp page..if i enter the value in textbox it should validate that it is present in XML file or not...i have an idea how to do using Database...but no idea how to check the entered value in XML file..can you suggest me the solution..
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmmm, no you need to read your xml file to do that validation
sting matching operation for stting you are reading with value of your xml file ....

you are wrokining in which company ?
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i didnt got your point i work in IBM..what about you
 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Pune IBM ? , i am with Geometric ...
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no from chennai,i need help can you suggest me what to do..its urgent
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its urgent

EaseUp.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ravi are you there
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic