Link to home
Create AccountLog in
Avatar of CIPL-Senthil
CIPL-Senthil

asked on

JSTL <c:import> Problem

Dear Experts,

Our application is based on struts and we are using JSP and JSTL in presentation layer.In one of our files we need to use <c:import>.I will provide the code for you for your reference

<c:import url="http://localhost:Bizpiper/flashdb.do?method=ContactInfo">
      <c:param name="proid" value="<%=p%>"></c:param>
      <c:param name="contactinfo" value="<%=a%>"></c:param>
      <c:param name="loginid" value="<%=loginid%>"></c:param>
      <c:param name="eName" value="<%=eName%>"></c:param>
</c:import>

Here we are executing the URL called "http://localhost:Bizpiper/flashdb.do?method=ContactInfo" with the mentioned parameters.after execution got completed i need to get status whether the execution is success or not.

Can you please suggest how i can do that.

Thanks
Malathi
Avatar of PrasathAnnamalai
PrasathAnnamalai
Flag of India image

you can check the status in the ContactInfo Method.
Avatar of CIPL-Senthil
CIPL-Senthil

ASKER

ya i have done the same by setting some status value in request scope.but it has not worked and i can not use  session scope variable for maintaning the single status variable.

Please advice
Avatar of rrz
Why not use   HttpURLConnection  ?    uses it behind the scenes anyway.  For testing try this JSP. If you don't want scriptlet on your page, then you can create tag file.

<%@ page import="java.util.*,java.net.*,java.io.*" %>
<%
  response.setContentType("text/plain");
  String url = "your_url_here_and_append_params";
  HttpURLConnection urlConnection = (HttpURLConnection)(new URL(url).openConnection());
  urlConnection.setDoInput(true);
  urlConnection.connect();
  BufferedReader reader = null;
  if(urlConnection.getResponseCode() ==  HttpURLConnection.HTTP_OK){
                reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
  } else {
          reader = new BufferedReader(new InputStreamReader(urlConnection.getErrorStream()));
      }
  String line = null;
  while((line = reader.readLine()) != null)out.print(line);
%>
Thanks for your suggestion.

I need some clarifications regarding URLConnection.According to my assumption the URL length will be restricted to some particular length.If we go on adding the parameters to that URL and if it is exceeding the restricted length of URL then can i know what kind of error i will get.

ASKER CERTIFIED SOLUTION
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Thanks a lot.your comment is very helpful to us.