Link to home
Start Free TrialLog in
Avatar of angel7170
angel7170Flag for United States of America

asked on

Redirect to Nav tabs from one jsp to another

Hi,

I have a JSP file named "addnew.jsp" which basically adds new record to a table and once completed, it should redirect to the list of records. The list of records are part of a tab named "#admin" in "index.jsp" file. Here is the code of the navigation tab from the index.jsp

 <ul style ="margin-bottom: 1px;" class="nav nav-tabs ">
                    <li role="presentation" class="active"><a data-toggle="tab" href="#Home">Home</a></li>
                    <li role="presentation"><a data-toggle="tab" href="#faq">FAQ</a></li>
                    <li role="presentation"><a data-toggle="tab" href="#admin">ADMIN TOOLS</a></li>
                </ul>

Open in new window


Here is the code for redirect but this doesn't land in the tab section. It takes to the home tab in index.jsp

  response.sendRedirect("index.jsp#admin"); 

Open in new window

Avatar of Jeffrey Dake
Jeffrey Dake
Flag of United States of America image

The # will anchor down to an Id of an HTML element. If you wan5 your page to anchor down you will need to add the Id to your element. 
Avatar of angel7170

ASKER

@Jeffrey -

I added Id="admin-tab" and referenced in the redirect but still it takes me to the home tab. Please help. Thanks

<ul style ="margin-bottom: 1px;" class="nav nav-tabs ">
                    <li role="presentation" class="active"><a data-toggle="tab" href="#Home">Home</a></li>
                    <li role="presentation"><a data-toggle="tab" href="#faq">FAQ</a></li>
                    <li role="presentation"><a id="admin-tab" data-toggle="tab" href="#admin">ADMIN TOOLS</a></li>
                </ul>

Open in new window


  response.sendRedirect("index.jsp#admin-tab");

Open in new window

SOLUTION
Avatar of Jeffrey Dake
Jeffrey Dake
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No problem.

Sorry to ask more questions. I should add the script as part of the redirect JSP, correct?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great. That worked. Thanks a lot!
Glad I could help