Yes, this can be achieved with a simple serlvet.
Suppose to say that you have list of href links in a table
1. Upon clicking on each href link direct it to your servlet.
Ex: < a href="/yourServlet.do?thirdPartyURL=actual3rdPartyURL">actual3rdPartyURL < / a>
- Validate this third party URL in your servlet code. If everything is okay
- Then redirect it with the SendRedirect method.
Note: it is not a good practice to show the URL in the browser address bar.
as you mentioned that, you are the one who populating this URLs, Use a hashmap to store these URL's and map it with Case ID and redirect it. hope you got the complete info.
Please check the below example and let me know if you need more info
/**
*
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
PrintWriter out = response.getWriter();
/**
* Assume that this is the map you are getting from third party
* This map holds two value pairs
* Map<CaseID, URL>
*/
Map<String, String> lstURLS = new HashMap<String,String>();
lstURLS.put("CASEID1", "https://www.abc.com/abc1");
lstURLS.put("CASEID2", "https://www.def.com/def");
lstURLS.put("CASEID3", "https://www.egh.com/egh");
/**
* Assume that the request parameter caseID,
* will provide you the case id which was selected by the user
* from the provided table of URLS
*/
String userProvidedCaseID = request.getParameter("caseID");
System.out.println("MySerlvet | caseID | "+ userProvidedCaseID);
/**
* Retrieve the URL from the list of third party URL's
*/
if(null != userProvidedCaseID){
String thirdPartyURL = lstURLS.get("userProvidedCaseID");
if(null != thirdPartyURL){
response.sendRedirect(thirdPartyURL);
}else{
out.print("No Case ID found / Error message");
}
}else{
out.print("No Case ID found / Error message");
}
}