Solved

How to make www.a.com/index.jsp?id=12345 to www.a.com/12345

Posted on 2006-11-11
4
286 Views
Last Modified: 2010-04-01
Hi,

  Is there anyway when user enter www.a.com/12345 which will equals to www.a.com/index.jsp?id=12345?

Bezier
0
Comment
Question by:bezier98
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 10

Expert Comment

by:jaggernat
ID: 17927572
make  "www.a.com/12345"  contain this code

----------------------
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<c:redirect url="www.a.com/index.jsp?id=12345?"/>
---------------------
and make sure you have c.tld in /web-inf.

what you are basically doing is when user types  www.a.com/12345, you are using the JSTL code <c:redirect..>
to redirect the user to www.a.com/index.jsp?id=12345?





0
 

Author Comment

by:bezier98
ID: 17927655
thanks jaggernat, but may be there is some misunderstanding:

12345 is actually an id, which can not be hardcoded, meaning the user might type

www.a.com/24680 and is actually calling www.a.com/index.jsp?id=24680

If you have experience in wordpress (although it's in php), they seems had implement similar logic, either access an archive blog by www.a.com/archive.php?id=whatever or www.a.com/archive/whatever

of course they may do it in other way round (i.e. forward archive.php to whatever, which is much easier.

To to ensure if we can do this in jsp or not.

Regards,
Bezier
0
 
LVL 10

Accepted Solution

by:
mbvvsatish earned 500 total points
ID: 17929243
try mapping the path / to a servlet or jsp

<servlet>
  <servlet-name>loginservlet</servlet-name>
  <servlet-class>/loginservlet</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>loginservlet</servlet-name>
  <url-pattern>/</url-pattern>
</servlet-mapping>

and in th loginservlet get the requested url using request.getRequestURL() that gives you the requested url from where you can get the *id* using substring.
and then dispatch the request using RequestDispatcher.forward("/index.jsp?id"+id)

this is just an idea that i got, i am not sure whether this works, but you can do something like this.
just try it and let me know.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Today’s effective marketing is about coming down to the customers’ level and engaging in a whole new way. A text message is one of the most effective and influential ways that you can engage your customers. Here are eight ways that you can utilize t…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question