Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2006-11-11
4
Medium Priority
?
296 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Sometimes Administrators rights are not enough. These cases call for the SYSTEM account. The process in this article outlines the steps required to execute commands using the SYSTEM account.
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

636 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