Solved

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

Posted on 2007-04-11
11
593 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet concurrency 13 133
struts spring hibernate example 12 143
Java Script nested call 3 91
DTD and JAVA versions 1 55
A hard and fast method for reducing Active Directory Administrators members.
Deploying our service is a grudge match between customer benefits and customer pain. In one corner, rolling out fixes (yay!) and delivering new features (double yay!). In the other corner, training on new features (boo – sounds like work), and chan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 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