Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7993575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:53:34+00:00 2026-06-04T13:53:34+00:00

I have a next question. In jsp page I use menu for 2 users

  • 0

I have a next question. In jsp page I use menu for 2 users ( tutor and student) in dependence on role I choose which from menu files I should include. Smth like this

<c:if test="${role eq 'Tutor'}">
                <c:import url="/page/menuForTutor.html" charEncoding="UTF-8"/>
</c:if>
<c:if test="${role eq 'Student'}">
             <c:import url="/page/menuForStudent.html" charEncoding="UTF-8"/>
</c:if>

I should use user descriptor

public class MenuTag extends TagSupport{

    private static final String PARAM_ROLE_TUTOR = "Tutor";
    private static final String PARAM_ROLE_STUDENT = "Student";

    @Override
    public int doStartTag(){
        HttpServletRequest request = (HttpServletRequest)pageContext.
                                                   getRequest();
        HttpSession session = request.getSession();
        String role = (String) session.getAttribute("role");
        if (PARAM_ROLE_TUTOR.equals(role)){
            try {
                pageContext.getOut().print("<c:import url=\"/page/menuForTutor.html\" charEncoding=\"UTF-8\"/>");
            } catch (IOException ex) {
                Logger.getLogger(MenuTag.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else if(PARAM_ROLE_STUDENT.equals(role)){
        }
        return SKIP_BODY;
    }       
}

When I use debag I see that I do all steps but menu for tutor wasn’t showed on jsp. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:53:36+00:00Added an answer on June 4, 2026 at 1:53 pm

    I assume that session(“role”) is set in another code part!

    set JspWriter out = pageContext.getOut();

    is something like following in the code

    JspFactory  factory     = JspFactory.getDefaultFactory();
    PageContext pageContext = factory.getPageContext(
    this,
    request,
    response,
    null,  // errorPageURL
    false, // needsSession
    JspWriter.DEFAULT_BUFFER,
    true   // autoFlush
    );
    
        ....
                JspWriter   out     = pageContext.getOut();
                HttpSession session = request.getSession();
                String role = (String) session.getAttribute("role");
                if (PARAM_ROLE_TUTOR.equals(role)){
                    try {
                        out.println("<c:import url=\"/page/menuForTutor.html\" charEncoding=\"UTF-8\"/>");
                        out.flush();
                        // Evaluate the body if there is one
                        return EVAL_BODY_BUFFERED;
    .......
    
    else return SKIP_BODY;
    

    EDIT see code: you have to “return EVAL_BODY_BUFFERED;”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have next question: I use liquibase maven plugin and by default when i
I have the next question: If I have a class which containts for instance
I have the next jsp file called Bookstore.jsp , in which I filled up
i have question about YAJLiOS parser... I have next json data : {{ body
I have next problem, when I'm trying to retrieve value from xforms:select elements I
I have the next query that I run via SQLCMD.EXE use [AxDWH_Central_Reporting] GO EXEC
have a next question: i.g. we have next html with structure: <html> <head> <script
I'm new in Android development and I have the next question/problem. I'm playing around
I'm new in Android development and I have the next question/problem. I'm playing around
Next question: I have InputDoc xml document and xslt file in order to transform

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.