Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem transfering info using a radio button

Status
Not open for further replies.

dexter195

Programmer
Jun 18, 2003
220
EU
hi,
im trying to transfer information from one jsp page to another.

im using a radio button to select the appropiate information and a submit button to transfer the selected username to another jsp page. that username will be used to perform a query on the database.

at the moment i can only transfer a string

Code:
<INPUT TYPE="radio" NAME="adminUsername" VALUE="bob">

what i want to do is send the value of username within an object.

eg: adminOutput.getUsername();

ive tried

Code:
<INPUT TYPE="radio" NAME="adminUsername" VALUE="<% adminOutput.getUsername(); %>">

but no information is being transfered. the data can be extracted from the above object so the info is there.
 
Remember that the JSP is compiled in the server.

If you want to get information after user interaction, that's done in the client side.

I don't know about the structure of your application, but I think that you couls store it in the session.

Cheers,

Dian
 
hi dian,

im using beans to store the data as its passed to each page. ive got other screens were the user can add info into a mysql database so my approach to passing the information with user interaction seems to be working.

its only when i try to set the value of the radio button with the jsp tag

value="<% variable %>"

im using a bean that stores this value. when i put a string without the <% %> tags

eg. value = "this is a test"

the data is passed to the bean on the recieving page and i can use this to run a query and then output what i need.

just to clarify what im trying to do.

i run a query that brings up a list of administrators.

this is run in a loop and their usernames etc and a radio button are put into rows in a table.

the user selects an administrator by checking the radio button beside his/her name. the value of the radio button is then set to this administrators 'username'.

the submit button is then pressed and the administrator details page is opened, and the value of hte username in the radio button is passed to it.

the username thats (supposed) to be sent to the bean is then used to run a query and then the results are outputted on the screen.

cheers for your help

dex
 
Sorry, I misunderstood your question

Try

Code:
<INPUT TYPE="radio" NAME="adminUsername" 
VALUE="<%=adminOutput.getUsername()%>">

Cheers,

Dian
 
excellent. that worked. i was expecting the lack of a ";" to cause an error.

thanks dian
 
It was not actually the ; but the = what you lack (does this construction make sense in english).

Cheers,

Dian
 
i had tried the = before and that got me nowhere. i never got rid of the ;.

i was under the impression that you needed the ; at the end of each line of code, in the same way as a regular java app requires.

what exactly is the difference.
is the = setting up the variables so that it just requires the object.method() info?

thanks again

dex
 
Its all about how the scriptlet tags are interpreted into the java class file (basically servlet) when your JSP is compiled.

When you type :

Code:
<%
   int myInt = 5;
%>

in the java class file it just gets copied verbose - so looks like :

Code:
   int myInt = 5;

Si if you miss off a ";" then the compiler will barf.

But the directive "<%= %>" is different.

This -
Code:
<%= myInt %>

gets converted to this :

Code:
out.println(myInt);

So if you typed "<%= myInt; %>" then this would barf - beacuse you cannot have a ";" inside a method.

--------------------------------------------------
Free Database Connection Pooling Software
 
ah that makes more sence.
so can the <%= be used for anything else other than

Code:
out.println(myInt);
[code]
 
hi

can anybody help me?

i have the same problem like the programmer before.

i am trying also to select a name from the radion button:

<input type="radio" name="vorname" value="<% ((FigurBezeichner) alleFiguren.get(i)).getVorname() %>">


the compiler said :
';' expected

can you help me, please....

nila
 
Same problem, same solution

Code:
<input type="radio" name="vorname"  value="<=% ((FigurBezeichner) alleFiguren.get(i)).getVorname() %>">

Cheers,

Dian
 
hi

ya but try , what you say

org.apache.jasper.JasperException

i dont why

what shall i do


this is my code


<html>

<head>

<title>update Peron</title>
</head>

<body bgcolor="#ffffff">
<form name="delete_namen" action="delete.jsp" method="post">
<div align="right">

<table width= "59%" border = "0" align = "center" cellpadding = "0" cellspacing = "0">

<td>&nbsp;</td>
<td>&nbsp;</td>
<tr>
<td valign="top"><b>Person auswählen und löschen</b><br> </td>
<td>



<%


for (int i = 0; i < alleFiguren.size(); i++)
{

String id = "";




//out.println("<a href=delete1.jsp?id="+((FigurBezeichner) alleFiguren.get(i)).getId()+">");

%>





<input type="radio" name="vorname" value="<=% ((FigurBezeichner) alleFiguren.get(i)).getVorname() %>">




%>


<%


}

%>







</td>


</tr>
<center>
<td colspan="15"><input type="Submit" name="submit" value="Delete"> <input type="reset" value="Zurücksetzen">
</center>

</table>



<p></p>

</body>

</html>




thanks
 
Humm, try to post your code between code tags.

The exception stacktrace would be useful.

Does the value render out of the radiobutton?

Cheers,

Dian
 
hi

when do so..

<input type="radio" name="vorname" value="<=%((FigurBezeichner) alleFiguren.get(i)).getNachname()%>">

the compiler only show the radio button, but not the names!

why????


thaks
 
hi

can you help me ?
i can only see the radio buttons but not the names!

why ???


regards
nila
 
Try including just <=%((FigurBezeichner) alleFiguren.get(i)).getNachname()%> in the JSP to check that the function is working properly.

Cheers,

Dian
 
you've got a slight typo in the starting tag on this line.
Code:
<=%((FigurBezeichner) alleFiguren.get(i)).getNachname()%>

it should be

Code:
<%=
hope that helps
 
hi

thank you so much. its working.
it took a long time, but with your help i can delete names now.

can you help in one more problem??? please

i have to update my fotos.the compiler gives me following mistake:


An error occurred at line: 29 in the jsp file: /Test/FOTO/foto_check.jsp
Generated servlet error:
/usr/local/jakarta-tomcat-5.0.28/work/Catalina/localhost/ortswexel/org/apache/jsp/Test/FOTO/foto_005fcheck_jsp.java:194: Foto(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) in database.Foto cannot be applied to ()
Foto neufoto = new Foto();
^


An error occurred at line: 29 in the jsp file: /Test/FOTO/foto_check.jsp
Generated servlet error:
/usr/local/jakarta-tomcat-5.0.28/work/Catalina/localhost/ortswexel/org/apache/jsp/Test/FOTO/foto_005fcheck_jsp.java:210: cannot resolve symbol
symbol : method updateFoto (database.Foto)
location: class database.FotoVerwalter
fotoVerwalter.updateFoto(neufoto);
^
2 errors


____________________________

but i dont know why "updateFoto(neufoto);" is wrong.
in the database its also called updateFoto.


can you help ???
i am really help less...
 
i could be wrong about this but it looks like your class "Foto" doesnt have an empty constructor, its expecting a load of strings instead.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top