Creating tabs in a jsp page

Hi All,

I am not very much familiar with jsp.My problem is.....

I am creating a jsp page in which i want 5 tabs, i know that it can be done using picture and corresponding jsp can be displayed on click event of the pictures. But I am not able to get through it.

Can anybody please help me some pease of code.

Thanx in advance.

[360 byte] By [ymi_abhia] at [2007-11-27 2:44:20]
# 1

This is just basic HTML knowledge, no need of JSP knowledge in here. Usually such a tab with a picture looks like:<a href="tab1.jsp"><img src="tab1.gif" /></a>

Or do you want to use frames? If so, as the use of frames is discouraged, I don't give any hints on this.

BalusCa at 2007-7-12 3:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks Balus for having a look on my problem. But my actual problem is wtth layout, by using hyperlink the control is transfered to next page, while what i need is that the content of each tab should be displayed on the same page.Thanks
ymi_abhia at 2007-7-12 3:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Then change the links by forms with an image as button and pass a hidden parameter along it indicating the filename of the tab. Retrieve this parameter in a jsp:include tag.

You can also use JS+DOM do display and hide block elements, but this requires that the content of all tabs have to be loaded at once, which isn't a good practice if the content of the tabs is relatively big.

BalusCa at 2007-7-12 3:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
I believe that the first idea will work for me, but if I could get some piece of code than it would be easier for me to get through it
ymi_abhia at 2007-7-12 3:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Basically:<form>

<input type="image" src="tab1.gif" />

<input type="hidden" name="tab" value="tab1" />

</form>

<jsp:include page="<%= request.getParameter("tab") + ".jsp" %>">

BalusCa at 2007-7-12 3:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Well it will work fine with my requirements but it showsan error stating attribute tab has no value in the line <jsp:include page="<%= request.getParameter("tab") + ".jsp" %>">
ymi_abhia at 2007-7-12 3:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Like I said, it is a basic example. You can build on it further. Yes, the request.getParameter("tab") might need a check if it is not null and if the supplied value is correct, etc. But this is not my task, you're the developer here :)
BalusCa at 2007-7-12 3:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
As i said I am new to JSPs that's why I asked this.Anyways Thanks a lot for your help. :-)
ymi_abhia at 2007-7-12 3:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
If you don't want to refresh your page by sending a request to server again, you may use javascript or AJAX.But the method above is much easier.
rym82a at 2007-7-12 3:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...