Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

if conditions that change HTML  RSS feed

 
Patrick Mallahan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to generate two different types of HTML based on a drop down that was selected from a previous page. So basically like:



that entire code would go in the JSP somewhere, I just dont know the syntax needed to print it out in the JSP. I know <%=variable %> prints a var but how do i print one using those test conditions?
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello patrick,
Scriptlet will help you in that,see the following pseudo code

<%
if(str1.equals(request.getParameter("var1")
{
%>
<%= str1%>
<%
}
%>
or else
you can write a custom tag to do the same job with no java code in JSP something like:

<request resent param="var1">
<%-- do something if parameter is present - -%>
</request resent>


I hope this helps you

Shrinivas
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is extermely basic stuff. If you're going to be delving into JSPs, I'd highly recommend taking a tutorial.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, if you're starting out with a JSP 2 container (which you should unless you've got a really good reason not to), you should get off on the right foot at the starting gate and use JSTL tags with the Expression Language in lieu of scriptlets for something like this.

The syntax for a simple test would be along the lines of:



a more complex test (if-then-else) could be:



[ July 22, 2005: Message edited by: Bear Bibeault ]
[ July 22, 2005: Message edited by: Bear Bibeault ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!