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 201073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:10:02+00:00 2026-05-11T17:10:02+00:00

I want to create a JSP page or servlet that will work in 2

  • 0

I want to create a JSP page or servlet that will work in 2 ways.

A user visits their own profile page:

http//something.com/profile/

Or they visit their friends page:

http://something.com/profile/FriendsName

They could also visit their own page through an explicit URL like:
http://something.com/profile/YourName

I have a servlet-mapping setup as follows to map any requests to /profile to my JSP that will handle that request.

  <servlet>
          <servlet-name>Profile</servlet-name>
          <jsp-file>/profile.jsp</jsp-file>
  </servlet>

  <servlet-mapping>
    <servlet-name>Profile</servlet-name>
    <url-pattern>/profile</url-pattern>
  </servlet-mapping>

Then I was thinking I could setup a filter that will parse the HTTPServletRequest’s URL to read after the /profile/.

  <filter>
    <filter-name>profile-filter</filter-name>
    <filter-class>ProfileFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>profile-filter</filter-name>
    <url-pattern>/profile*</url-pattern>
  </filter-mapping>

Now the filter could set attributes in the HttpServletRequest, how would i go about pulling those out in the JSP page to check if a user name was specified and check if your own name was set?

How would I go about creating a page scoped bean in the ServletFilter so I could use in the JSP page using jspBean like this:

<jsp:useBean id="profileInfo" scope="page" class="ProfileInfo" /> 
  • 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-05-11T17:10:02+00:00Added an answer on May 11, 2026 at 5:10 pm

    I think a filter only serves to artificially break the logic apart. You can very easily determine the value of the portion of the URL that doesn’t match the url-pattern described in the web.xml. The HttpServletRequest class has a method that returns this value for you, it’s called getPathInfo(). Here’s an example:

    <%
       String path = request.getPathInfo();
       if (path == null || "".equalsIgnoreCase(path)) {
          // The path was empty, display the current user's profile
       } else {
          // Display the named profile
       }
    %>
    

    This doesn’t help you at all with the request beans, but I think it helps with the design.

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

Sidebar

Related Questions

I want to create a login page using Servlet & JSP. I ve created
I want to create a Thread safe JSP page. It is possible in Servlet
I want to create a simple http proxy server that does some very basic
I want to use google maps in JSP page, I tried to create it,
I want to create a client side mail creator web page. I know the
I want to create a function that performs a function passed by parameter on
I'm doing one litle project with JSP for topic Library. I want to create
I want to use a temp directory that will be unique to this build.
I am fairly new to JSP , i learned that to create a variable
Is there a way to create the Servlet (page display - form) and process

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.