Solved

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

Posted on 2006-11-11
4
280 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
  • 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

Expert Comment

by:jaggernat
ID: 17927671
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

776 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