• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

if conditions that change HTML

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic