Click here to Skip to main content
15,892,737 members
Home / Discussions / Java
   

Java

 
GeneralRe: 5 drawings in 5 rectangular regions within one window Pin
WebMaster25-Oct-09 2:28
WebMaster25-Oct-09 2:28 
GeneralRe: 5 drawings in 5 rectangular regions within one window Pin
427748025-Oct-09 4:29
427748025-Oct-09 4:29 
QuestionJPanel Field day issues Pin
shawndeprey23-Oct-09 3:46
shawndeprey23-Oct-09 3:46 
AnswerRe: JPanel Field day issues Pin
427748024-Oct-09 0:55
427748024-Oct-09 0:55 
GeneralRe: JPanel Field day issues Pin
shawndeprey24-Oct-09 19:52
shawndeprey24-Oct-09 19:52 
GeneralRe: JPanel Field day issues Pin
427748025-Oct-09 0:10
427748025-Oct-09 0:10 
GeneralRe: JPanel Field day issues Pin
shawndeprey25-Oct-09 4:18
shawndeprey25-Oct-09 4:18 
Questionview page source (of a webpage) Pin
sharkbc22-Oct-09 17:56
sharkbc22-Oct-09 17:56 
Hi all !

I want to receive page source from a hyperlink.

This is may code

public class SourceViewer{
  public static void main (String[] args) throws IOException{
	  
	  
    System.out.print("Enter url of local for viewing html source code: ");
    
    
    //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   // String url = br.readLine();
    //http://vdict.com/Hello,1,0,0.html
    String url = "http://vdict.com/Hello,1,0,0.html";
    try{
      URL u = new URL(url);
      HttpURLConnection uc = (HttpURLConnection) u.openConnection();
      int code = uc.getResponseCode();
      String response = uc.getResponseMessage();
      System.out.println("HTTP/1.x " + code + " " + response);
      for(int j = 1; ; j++){
        String header = uc.getHeaderField(j);
        String key = uc.getHeaderFieldKey(j);
        if(header == null || key == null)
          break;
        System.out.println(uc.getHeaderFieldKey(j) + ": " + header);
      }
      InputStream in = new BufferedInputStream(uc.getInputStream());
      Reader r = new InputStreamReader(in);
      int c;
      while((c = r.read()) != -1){
        System.out.print((char)c);
      }
    }
    catch(MalformedURLException ex){
      System.err.println(url + " is not a valid URL.");
    }
    catch(IOException ie){
      System.out.println("Input/Output Error: " + ie.getMessage());
    }
  }
}


it work well with some link.

But problem with this link:
http://vdict.com/Hello,1,0,0.html[^]


this is the result form browser and my program:

-Browser:you can see by your self.
-My program:

Date: Fri, 23 Oct 2009 03:53:22 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.1.6
Expires: Fri, 30 Oct 2009 03:53:22 GMT
Cache-Control: max-age=360000, must-revalidate
Pragma: public
Last-Modified: Fri, 23 Oct 2009 03:53:22 GMT
Vary: Accept-Encoding
Content-Length: 2102
Content-Type: text/html; charset=UTF-8
Set-Cookie: PHPSESSID=4hgviiktc0gc38aiotd8s6jn37; path=/
Connection: Close
 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
	<meta name='description' content='Vietnamese dictionary and translation for mobile phones and PDAs'>
	<meta name='keywords' content='vietnamese, dictionary, translation, mobile phones, pda, nokia, iphone, blackberry'>
	<meta name='robots' content='index, follow' />
	<meta name='revisit-after' content='1 days' />
	<meta name='resource-type' content='document' />
	<title>Vietnamese Dictionary for Mobile phones and PDAs</title>
	<link href='libs/loadstatic/m.css' rel='stylesheet' type='text/css' />
</head>
<body>
<div class="container">
  <div class="header">VDict mobile</div>
  <div class="menu"><strong>Dictionary</strong> - <a href="t.php">Translation</a></div>  <div class="searchform">
    <form name="frmlookup" id="frmlookup" action="/" method="get" style="margin:0">
      <input name="word" type="text" class="forminput" size="30" value="" />
      <br />
      <select name="dict" class="formselect" >
        <option value="1">English - Vietnamese</option>
        <option value="2">Vietnamese - English</option>
        <option value="3">Vietnamese - Vietnamese</option>
        <option value="5">French - Vietnamese</option>
        <option value="4">Vietnamese - French</option>
        <option value="6">Computing</option>
        <option value="7">English - English</option>
        <option value="8">Chinese - Vietnamese </option>
        <option value="9">Russian - Vietnamese</option>
      </select>
      <br />
      <input name="searchaction" type="submit" value="Lookup" class="subbut" />
    </form>
<div class="result"><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />    </div>
  </div>
  <div class="footer">&copy; Vdict mobile (<a href="http://vdict.com/?ndr=1">Switch to full version</a>) </div>
</div>
</body>
</html>



Can anybody tell me about this problem and how to fix it.

Thanks and regards !
AnswerRe: view page source (of a webpage) Pin
427748024-Oct-09 0:58
427748024-Oct-09 0:58 
QuestionWrite a java applet to multiply 2 numbers Pin
Shah Ravi22-Oct-09 17:54
Shah Ravi22-Oct-09 17:54 
AnswerRe: Write a java applet to multiply 2 numbers Pin
Shah Ravi22-Oct-09 18:50
Shah Ravi22-Oct-09 18:50 
AnswerRe: Write a java applet to multiply 2 numbers Pin
Richard MacCutchan23-Oct-09 4:05
mveRichard MacCutchan23-Oct-09 4:05 
AnswerRe: Write a java applet to multiply 2 numbers Pin
shawndeprey23-Oct-09 4:51
shawndeprey23-Oct-09 4:51 
GeneralRe: Write a java applet to multiply 2 numbers Pin
Richard MacCutchan23-Oct-09 5:23
mveRichard MacCutchan23-Oct-09 5:23 
GeneralRe: Write a java applet to multiply 2 numbers Pin
shawndeprey23-Oct-09 16:17
shawndeprey23-Oct-09 16:17 
GeneralRe: Write a java applet to multiply 2 numbers Pin
David Skelly23-Oct-09 6:44
David Skelly23-Oct-09 6:44 
GeneralRe: Write a java applet to multiply 2 numbers Pin
Richard MacCutchan23-Oct-09 6:55
mveRichard MacCutchan23-Oct-09 6:55 
AnswerRe: Write a java applet to multiply 2 numbers Pin
427748024-Oct-09 1:02
427748024-Oct-09 1:02 
Question[Message Deleted] Pin
teknozwizard21-Oct-09 21:03
teknozwizard21-Oct-09 21:03 
AnswerRe: Trouble With Rotating Script Pin
David Skelly21-Oct-09 22:09
David Skelly21-Oct-09 22:09 
Questionsimple chat Pin
ammu2321-Oct-09 18:27
ammu2321-Oct-09 18:27 
AnswerRe: simple chat Pin
Richard MacCutchan21-Oct-09 23:23
mveRichard MacCutchan21-Oct-09 23:23 
GeneralGoogle Sitebricks demo with db4o Pin
netquake21-Oct-09 3:03
netquake21-Oct-09 3:03 
GeneralRe: Google Sitebricks demo with db4o Pin
Eddy Vluggen21-Oct-09 4:27
professionalEddy Vluggen21-Oct-09 4:27 
Questionreturn back to my application. Pin
sangeethanarayan21-Oct-09 3:00
sangeethanarayan21-Oct-09 3:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.