Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Aug 2010
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How to create dynamic public user profile for my website

    Hi experts,

    I created my wbsite and user will register in my website and will log in.
    I want to create public profile for every user like in linkedin, feacebook etc.

    for ex.

    www.mywebsite.com/user/username

    But I don't know how to do this.
    please help me..

    Thanks in advance,
    yuvi..

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Although the implementation of this will be language specific (assuming you are using JSP since this is in the Java forum), this is actually performed by apache with a module called mod_rewrite.
    This looks like a pretty good tutorial and should help you get started: http://articles.sitepoint.com/articl...-url-rewriting. The last page pretty much shows what you are looking to do.

    Moving from Java to Apache Configurations.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Aug 2010
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hello,

    Thank you for turn me to the right direction. I visited that page but I don't know how to proceed. whether we have to use perl to do this or we can do this with java itself.

    Help me to proceed..

    I think it is the long process to go.
    Can you show me any sample code in java??


    Thanks and Regards,

    yuvi...

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    URL rewriting isn't done by any language. Its done by apache, you take the new url and map it back to what you want it to be which will be a querystring design.
    You retrieve these in JSP from the request.getParameter method.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    So for example with URL rewriting if the user requests:

    mysite.com/user/someuser
    you can rewrite it so the page that is actually requested on the server (as an example) is:
    mysite.com/showuser.php?user=someuser

    It is language independent so it doesn't matter what server side language you are using.
    OracleGuy

  • #6
    New Coder
    Join Date
    Aug 2010
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts
    But I am developing my website in netbeans IDE in java platform and my website is running in my own system localhost not in internet.

    My doubt is Where Can I save .htaccess file in order to run in netbeans IDE for url rewriting?

    I test this one in php in xampp and it is working. I got the result I want.

    But in jsp, I can't do that.

    actually my project link to view the public profile for specific user is

    http://localhost:8080/project/public...serid=username

    I want to rewrite as http://localhost:8080/project/username

    How can I access .htaccess file for my project through netbeans IDE.

    Thanks in advance,

    yuvi..
    Last edited by yuvi; 08-12-2010 at 12:13 PM. Reason: I tried in php and it is working. But not in jsp

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I'm not familiar with how the netbeans works for this, but I believe JSP often uses Apache and Tomcat to run. So I don't see an issue with using .htaccess files if thats the case.
    Generally you need to make these files yourself, if you don't see one its possible that it doesn't yet exist. If it does, you can access it using any text editor including notepad.
    Windows may give you a hard time making .htaccess files though. Make sure your extensions are showing, and using a command window execute echo "" > .htaccess when you are in the proper directory. This is if your on windows.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    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
    •