angel7170
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
Here is the code for redirect but this doesn't land in the tab section. It takes to the home tab in index.jsp
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>
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");
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.
ASKER
@Jeffrey -
I added Id="admin-tab" and referenced in the redirect but still it takes me to the home tab. Please help. Thanks
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>
response.sendRedirect("index.jsp#admin-tab");
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No problem.
Sorry to ask more questions. I should add the script as part of the redirect JSP, correct?
Sorry to ask more questions. I should add the script as part of the redirect JSP, correct?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great. That worked. Thanks a lot!
Glad I could help