Solved

is it possible to query imdb.com from my website using a jsp page

Posted on 2007-04-11
11
591 Views
Last Modified: 2008-01-09
I wanted to write a JSP page for my website that would allow a user to enter a movie name and then query IMDB.com and display the page with the info on that movie.  Is this possible, and if so how would I do it?

thanks!
0
Comment
Question by:urobins
  • 6
  • 5
11 Comments
 
LVL 27

Accepted Solution

by:
rrz earned 500 total points
ID: 18892605
Here is a start.
<%@ page import="java.net.*,java.io.*" %>
<%
        String movieTitle = request.getParameter("movieTitle");
        if(movieTitle == null)movieTitle = "Casablanca";
        String movieTitleEncoded = URLEncoder.encode(movieTitle, "UTF-8");
        URL url = new URL("http://imdb.com/find?s=all&q=" + movieTitleEncoded);
        URLConnection conn = url.openConnection();
        conn.setDoOutput(true);
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        while ((line = rd.readLine()) != null) {
           // parse the parts you want to display
            out.print(line);
        }
        rd.close();
%>
0
 

Author Comment

by:urobins
ID: 18892654
sorry I am new to JSP I would like to just display the whole page in return, how would I do that?
0
 
LVL 27

Expert Comment

by:rrz
ID: 18892990
Use the following page to call the page I posted in my first post.
<html>
<head>
<title>Movie Info</title>
</head>
<body>
<form action="getMovieInfo.jsp">
Please enter movie title:<input type="text" size="25" name="movieTitle"/>
<input type="submit" value="Get movie info"/>
</form>
</body>
</html>

But if you want the whole page you don't even need JSP. You could use the following in a frame on one of your HTML pages.  
<html>
<head>
<title>Movie Info</title>
<script>
function GetInfo(){
  window.location = "http://imdb.com/find?s=all&q=
                   + encodeURIComponent(document.movieForm.movieTitle.value);
}
</script>
</head>
<body>
<form name="movieForm">
Please enter movie title:<input type="text" size="25" name="movieTitle"/>
<input type="button" value="Get movie info" onclick="GetInfo();"/>
</form>
</body>
</html>
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 

Author Comment

by:urobins
ID: 18893010
Thanks let me try this  I appreciate the help.  Now you say I can parse just certain parts, but I would need to know what they were called on IMDB Right?  I am just confused at how to pull info from a site I don't manage.  I have looked for some tutorials  but haven't found a whole lost using JSP and my book isn't all that great either.
0
 
LVL 27

Expert Comment

by:rrz
ID: 18893086
Which book are you using ?
There is a lot of info online. Google is your friend.
0
 

Author Comment

by:urobins
ID: 18893103
How do I get it so I can use the Hyperlinks on the returned page?
0
 
LVL 27

Expert Comment

by:rrz
ID: 18893108
>Now you say I can parse just certain parts  
But, I didn't say it would be easy.  Depends on what you want to do.
0
 

Author Comment

by:urobins
ID: 18893123
I bought Beginning Java EE5.  I found a lot of JSP info online but a lot of it is over my head, or too basic "hello world" world examples.  Thanks again.  I can get it to return the IMDB page but I have the problem where a movie title will return multiple matches and I can't select them...
0
 

Author Comment

by:urobins
ID: 18893129
>But, I didn't say it would be easy.  Depends on what you want to do

Oh :)  thats probly much greater than where I am at huh :)

thanks for all of your help.
0
 
LVL 27

Expert Comment

by:rrz
ID: 18893239
I haven't read that book. But I recommend you read  
http://java.sun.com/javaee/5/docs/tutorial/doc/
0
 

Author Comment

by:urobins
ID: 18893305
Thank you!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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