Results 1 to 7 of 7
  1. #1
    kavithav is offline Member
    Join Date
    Apr 2017
    Posts
    26
    Rep Power
    0

    Default How to hide View Reports which is the second list item with id="MenuReports" based on

    In my application i have three listitems File Upload,View Reorts and Change Password.I need to hide View Reports if the login is by normal user and i need to display View Reports if the login is by manager.Below is the code of my tabs

    Java Code:
    <div class="wrapper">
            <div class="menu">
                 <div class="menu">
                    <ul id="drop-nav">
                        <li id="MenuFileUpload" runat="server"><a href="Upload.jsp">File Upload</a>
                            <ul>
                                <li><a href="ViewUploadedFiles.jsp">View Uploaded Data</a></li>
                            </ul>
                        </li>
                         <li id="MenuReports" runat="server"><a href="Reports.jsp" id="Rpf" runat="server">View Reports</a><ul>
                             <li><a href="Reports1.jsp">Report1</a></li>
                             <li><a href="Reports2.jsp">Reports2</a></li>
                             <li><a href="Report3.jsp">Report3</a></li>
                             </ul>
                         </li>
                             <li id="lichangepwd" runat="server"><a id="A1" href="ChangePassword.jsp" runat="server">Change Password</a></li>
                        <div style="width:auto;float:right;font-weight:bold;padding-right:0cm;">
                            <li id="lilogout"><a href="Logout.jsp"> Logout</a></li></div>
                         <div style="float: left;text-align:right; width: 64%;"> 
                        <asp:Label ID="lblmsg" runat="server" ForeColor="Red" BorderColor="White" Text="Label" Font-Size="Small"></asp:Label> </div>
    
                    </ul>
    
                 </div>
    
            </div>
    Below is my servlet code how to hide view reports tab based on the login

    Java Code:
    if(role.equals("Supervisor"))
       {
          response.sendRedirect("SupervisorMaster.jsp");
       }
       else if(role.equals("User"))
       {
             response.sendRedirect("SupervisorMaster.jsp");  
       }
    Last edited by Tolls; 07-26-2017 at 12:19 PM. Reason: Added code tags

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: How to hide View Reports which is the second list item with id="MenuReports" base

    Not too sure what the flow is there, as both the if and else parts of that statement go to the same JSP page.
    Also, why "redirect" and not "forward"? In general the browser should not have access to the JSP page directly, just the servlets.

    Finally, you could simply stick a jstl 'if' tag around that <li>, checking for role.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    kavithav is offline Member
    Join Date
    Apr 2017
    Posts
    26
    Rep Power
    0

    Default Re: How to hide View Reports which is the second list item with id="MenuReports" base

    i am getting the role here into the string String role = rs.getString("role"); but based on this role i need to hide the reports to users currently i am redirecting to same master page

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: How to hide View Reports which is the second list item with id="MenuReports" base

    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: How to hide View Reports which is the second list item with id="MenuReports" base

    But why redirect instead of forward?

    And why bother with the if at all if it is only going to the same place?

    Anyway, you need to put the role into the request and then forward to the page (this is why I'm asking about why the redirect).
    Then you can use the JSTL if tag to wrap the <li> block you want to hide.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    kavithav is offline Member
    Join Date
    Apr 2017
    Posts
    26
    Rep Power
    0

    Default Re: How to hide View Reports which is the second list item with id="MenuReports" base

    could you please show me how to do that i am unable to get it

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: How to hide View Reports which is the second list item with id="MenuReports" base

    Java Code:
    request.getRequestDispatcher("where you want to go").forward(request, response);


    RequestDispatcher (Java EE 6 ), javax.servlet.ServletResponse)

    That way all the details in the request are available to the JSP page, including anything you add to it using setAttribute.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 2
    Last Post: 08-03-2014, 06:23 AM
  2. Replies: 1
    Last Post: 12-04-2013, 09:32 PM
  3. Replies: 0
    Last Post: 08-22-2012, 01:04 PM
  4. problem with argument list and precedence "(" and ")"
    By helpisontheway in forum Advanced Java
    Replies: 6
    Last Post: 12-24-2009, 07:50 AM
  5. Replies: 0
    Last Post: 03-15-2009, 11:53 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •