i try to change this scrip into jsp but i stuck at switch statement - switch ($_GET.. Please someone help me.. (T_T)

menu.php

<li><a href="index.php?action=home">Home</a></a></li> 
<li><a href="index.php?action=aboutus">About Us</a></a></li>

index.php

<td width="20%" valign="top">
    <?php include ('menu.php'); ?>
    </td>
    
    <td width="85%" valign="top">
	<?php
    	switch ($_GET['action']){
		case 'aboutus': 
				include 'aboutus.php';
				break;

		case 'home':
				include 'home.php';
				break;

     		default:
				include 'home.php'; 
        }
	?>

Recommended Answers

All 4 Replies

Do you have any knowledge of java? Or any other programming language? The switch is the classic switch statement that you will find in any language. You will need to use scriplets. Try to find and read a book about jsps. If you are unfamiliar with java then you shouldn't be writing jsp and you should be learning java first.
I believe that someone should be very good in java before going to jsps

Do you have any knowledge of java? Or any other programming language? The switch is the classic switch statement that you will find in any language. You will need to use scriplets. Try to find and read a book about jsps. If you are unfamiliar with java then you shouldn't be writing jsp and you should be learning java first.
I believe that someone should be very good in java before going to jsps

yes i know. what i means is how to display multiple page with one layout for example index.jsp?action=about is that jsp do not use switch to do that?

If you know how to use the switch in java, then you need to search for the "include" tag used in jsp

i found the solution.. jsp is using request.getParameter()

when i click register link (menu.asp) it will include register.asp file in the index.jsp
the url will be like this http://.../index.jsp?page=register..
by default it view a home.jsp..

menu.asp

<a href="index.jsp?page=register">Register here!</a>

index.jsp

<% 
   if (request.getParameter("page") != null) {%>
     <%@ include file="register.jsp" %>
     <% }
   else { %>
     <%@ include file="home.jsp" %>
   <% }
%>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.