Jsp help

Hi,

I have an .html, and this .html has two checkboxes.,

<input type="checkbox" name="oop" value="circle" />

<input type="checkbox" name="oop" value="cilinder" />

and is "connected" to work with a .jsp.

<form action="2.jsp" method="post" >

What I want is that when i choose, for example the "circle" checkbox,

a result/output will be displayed in the 2.jsp.

But if I choose "cilinder" checkbox, another diferent result will be displayed in the 2.jsp.

How can I do this?

thanks for any response...

[782 byte] By [deroka] at [2007-11-27 4:43:12]
# 1

Which part of the coding don't you understand or can't you achieve? Please ask specific questions.

Firstnext step is to read the [url=http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletRequest.html]HttpServletRequest API documentation[/url] and then especially the getParameterValues() method.

By the way, if you actually want single selections and not multiple selections, then use input type="radio" instead. As far I understand you likely want single selections.

BalusCa at 2007-7-12 9:54:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
What I cant achieve right now is that:Depending on the selection made, a diferent output is displayed.
deroka at 2007-7-12 9:54:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Just determine the selecton in an if-else statement and handle accordingly.
BalusCa at 2007-7-12 9:54:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Ok, look at this:

in .html:

<input type="checkbox" name="circle" />

in .jsp:

if(request.getParameter("circle").equals("on") )

{

<input name="name1" type="text">

<input type=submitvalue=Execute>

}

This obviously sends me an error, but is what I am trying to achieve:

If the checkbox is selected("on"), then, display a "text", and a submit Button.

how can I do that?

deroka at 2007-7-12 9:54:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

With scriptlet code, you need to embed the java stuff in <% %>, ant the html template text outside of it.

<%

if (request.getParameter("circle") != null){

%>

<input type="test" name="name1" >

<input type="submit" value="Execute">

<% } %>

With JSTL

<c:if test="${not empty param.circle}">

<input type="test" name="name1" >

<input type="submit" value="Execute">

</c:if>

Cheers,

evnafets

evnafetsa at 2007-7-12 9:54:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
thanks guys...
deroka at 2007-7-12 9:54:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...