I’m writing an application in JSP that needs to reach out to a remote cgi which will feed it some data.
Is there a JSP specific way to do this that is less brute force than simply using the httpConnection library and reading a bitstream?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use JSTL
<c:import>tag to import response data from external resources in your JSP page.But if this returns a complete HTML page of which you just need a certain part, then you really need to do a bit more work. Best way would be to create a
Servletclass which preprocesses this data before forwarding the request to the JSP page. You can usejava.net.URLto get anInputStreamfrom it which you feed to a HTML parser to get the necessary information out of it. Here’s a basic example:and then in JSP just access the
databy EL:Edit: as per the comments, you need the
<c:import>in combination with thevarattribute. You can then usefn:split()afterwards to split the obtainedkey:valuestring.