Solved

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

Posted on 2006-11-11
4
277 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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 
LVL 10

Accepted Solution

by:
mbvvsatish earned 500 total points
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now