wood burning stoves 2.0*
The moose likes Servlets and the fly likes Know technique for dynamic URL change Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Know technique for dynamic URL change" Watch "Know technique for dynamic URL change" New topic
Author

Know technique for dynamic URL change

Ramesh Sengani
Ranch Hand

Joined: Nov 23, 2011
Posts: 36
Hi,

I am working on real estate forum site where person can add there personal opinions , questions ,solutions etc.

I want to make that site SEO friendly.for that i need topic's Subject/title in url .
for coderanch Eg. http://www.coderanch.com/t/572347/Servlets/java/Servlet-Asynchronous-Operations

http://www.coderanch.com/t/572113/Web-Services/java/SOAP-REST-tightly-loosely-coupled

above url changing for each topic.how this i make possible by using java ,servlet ?
Dhaval J. Patel
Ranch Hand

Joined: Mar 10, 2011
Posts: 90

Google search URL rewriting.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41601
    
  55
The only required part is everything up to the thread ID (http://www.coderanch.com/t/572113/), everything behind that is not significant and can be chosen at will (or left out altogether). So there's no "rewriting" going on here.


Ping & DNS - my free Android networking tools app
Ramesh Sengani
Ranch Hand

Joined: Nov 23, 2011
Posts: 36
Yes i agree with Marshal.. But In my servlet code i make that possible.? i am not getting any idea
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41601
    
  55
Making what possible? Creating URLs that contain parts which your web app simply ignores?
Ramesh Sengani
Ranch Hand

Joined: Nov 23, 2011
Posts: 36
i need that technique in my project. how do i make that possible in project. Suggest with some good example if you can. I am using Servlet + struts2
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41601
    
  55
Ulf Dittmer wrote:Making what possible?

It's a URL to which you append whatever strikes your fancy when you display it someplace. Are you asking how to do string concatenation?
Ramesh Sengani
Ranch Hand

Joined: Nov 23, 2011
Posts: 36
I need in struts2. Is possible for you to give some small example on it
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41601
    
  55
An example of what? What, specifically, are you struggling with to implement?
Wayan Saryada
Ranch Hand

Joined: Feb 05, 2004
Posts: 105

I think what Ramesh want is how he can create or implement a SEO friendly url in his Struts application.


Website: Learn Java by Examples
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41601
    
  55
But there's nothing to it. If "http://www.coderanch.com/t/572113/" is the integral URL, all you need to do is to set up whatever code handles "/t" URLs to extract the ID from the URL and ignore everything that comes after it.
Ramesh Sengani
Ranch Hand

Joined: Nov 23, 2011
Posts: 36
Thanks for understanding my need Wayan..

Ulf Dittmer you are right but how can i cancat title or subject of topic before fetch. As per your suggestion "http://www.coderanch.com/t/572113/" based on 572113 id i will fetch topic from db. but i need url like this http://www.coderanch.com/t/572347/Servlets/java/Servlet-Asynchronous-Operations ,which is not possible before fetching..


Sorry i am stretching this topic but solution is really helpful for me
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41601
    
  55
What do you mean by "fetching", and what does a DB have to do with non-functional parts of an URL? Wherever you want to display the URL, just append whatever you want appended, and then ignore it when interpreting it on the server. That has no bearing on how the page that's behind the URL is stored or retrieved.
John McCall
Greenhorn

Joined: Apr 05, 2012
Posts: 1
Thanks guys, this post helped me a lot, I was going to ask about this issue but I found that Ramesh already asked it

I appreciate your efforts..

Thanks again
 
jQuery in Action, 2nd edition
 
subject: Know technique for dynamic URL change