Home > Default > Need JSP-URL in controlling servlet

Need JSP-URL in controlling servlet

November 30Hits:0
Advertisement
Hi,
I have a simple questions which is driving me crazy.
2 JSP's are using same Servlet which has to process their input.
Inside this servlet I need to know which jsp is calling the servlet.
I tried following code :
          System.out.println("req.getRequestURI() = \"" + req.getRequestURI() +"\"");
          System.out.println("req.getClass() = \"" + req.getClass() +"\"");
          System.out.println("req.getPathInfo() = \"" + req.getPathInfo() +"\"");
          System.out.println("req.getPathTranslated() = \"" + req.getPathTranslated() +"\"");
          System.out.println("req.getServletPath() = \"" + req.getServletPath() +"\"");
          System.out.println("HttpUtils.getRequestURL(req)= \"" + HttpUtils.getRequestURL(req) +"\"");
but none of them are returning the correct name of the calling JSP...
Here are the results in same sequence:
req.getRequestURI() = "/servlet/com.clipper.servlets.FQController"
req.getClass() = "class com.ibm.servlet.engine.webapp.WebAppDispatcherRequest"
req.getPathInfo() = "null"
req.getPathTranslated() = "null"
req.getServletPath(req) = "/servlet/com.clipper.servlets.FQController"
HttpUtils.getRequestURL()= "http://www.clippersupport.be:2031/servlet/com.clipper.servlets.FQController"
As you can see, I only retrieve the Servlets info, not the JSP's...
I need to find :
/JSP/JSP1.jsp
How do I do this ???

Answers

I don't think it is possible to find out the details of the calling jsp in another servlet jsp or servlet. The only possibility is in the jsp get requestURL and place this as a request parameter in the request. Then when you call the servlet, the servlet can then extract this request parameter.

Read other 3 answers

Tags:

Related Articles

  • Need JSP-URL in controlling servletNovember 30

    Hi, I have a simple questions which is driving me crazy. 2 JSP's are using same Servlet which has to process their input. Inside this servlet I need to know which jsp is calling the servlet. I tried following code :           System.out.println("req.

  • How to get the query values from the url in a servlet and pass them to jspOctober 11

    ok..this is the situation... all applications are routed through a login page... so if we have a url like www.abc.com/appA/login?param1=A&param2=B , the query string must be passed onto a servlet(which is invoked before the login page is displayed)..

  • Filter does not work with *.jsp URL pattern???October 11

    Hi All, I am, by no means, very good at JSF or Java. I have looked at various forum posts on here for ways to implement a security filter to intercept requests to pages that first require one to be logged in, and if not, redirect them to the login pa

  • Why jsp is converted into servlet?November 30

    hi, Why the jsp is converted into servlet in the container? reason? why cant is evalute as a jsp file itself? why did not they develope a seperate container for jsp?hi :-) Why the jsp is converted into servlet in the container? reason? why cant is ev

  • JSP Redirection fails, from ServletNovember 30

    Hi I have simple web application, where im doing some java operation in servlet and Req dispatching to JSP page Most of the the times, on first request i see JSP null pointer exception and in the next request service runs fine. Below is the error msg

  • jsp:include from a Servlet???November 30

    Hi guys, Does anybody know if there is a way of using <jsp:include> from a servlet?? It would save me alot of hassle!!Of course <jsp:include> is a JSP tag so it requires JSP :-). It is not clear exactly what you want to do, but here is one way

  • How to map ALL .jsp to a Main servlet ?November 30

    the problem is that i want to submit all forms on web pages to be processed by servler but to see in adress bar of my browser url with .jsp i tried to map main sertvlet in such a way <url-mapping>/*.jsp</url-mapping> but it didn't work... is t

  • No parms passed to controlling servletNovember 30

    I want a page with an inputfield, 2 selectboxes and 1 (or more) submit-buttons. User MUST select a button before 'controlling servlet' is executed. (I mean, no action when 'enter' is used). These are the 2 scenarios I tried: Scenario (A) When i put t

  • How to get multiple selections from jsp page in my servletOctober 11

    Hello Everyone, I've a list that allows users to make multiple selections. <select name=location multiple="multiple">     <option>          All     </option>     <option>          Hyd     </option>     <option>

  • "Source not found" Error creating URL Data control with query parametersOctober 11

    Hi, I have a restful service for which i want to create a URL data control. I am able to create the URL data control successfully when i am not passing any parameters in the Source field. But if i am specifying the parameters in the source field like

Copyright (C) 2019 wisumpire.com, All Rights Reserved. webmaster#wisumpire.com 14 q. 0.644 s.