3

I am developing an application in which i have to read the contents of the url and after giving request parameter to it i have to post that request back to the server. I have used Jsoup library for fetching the response. But the response is not fetched when i give my url ("http://10.100.56.55:8090") which is for cyberoam. I am developing application for automatically make login into the cyberoam. Now if i give any other url then my code is working just fine. But for this url the exception is thrown which is written here.

Code :

ResourceBundle rb = ResourceBundle.getBundle("bundle.Configuration");                              
try
{             
    Document doc=Jsoup.connect(rb.getString("cyberlink_url")).get();
}
catch (Exception e) 
{
    System.out.println("Error Class is :- " + e.getClass());
    e.printStackTrace();
}

Error :

Error Class is :- class java.nio.charset.IllegalCharsetNameException
java.nio.charset.IllegalCharsetNameException: UTF=8
    at java.nio.charset.Charset.checkName(Charset.java:320)
    at java.nio.charset.Charset.lookup2(Charset.java:496)
    at java.nio.charset.Charset.lookup(Charset.java:475)
    at java.nio.charset.Charset.forName(Charset.java:540)
    at org.jsoup.helper.DataUtil.parseByteData(DataUtil.java:78)
    at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:440)
    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:133)
    at cyberoam.Cyberoam.btnLoginActionPerformed(Cyberoam.java:199)
    at cyberoam.Cyberoam.access$000(Cyberoam.java:24)
    at cyberoam.Cyberoam$1.actionPerformed(Cyberoam.java:82)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    .......

The problem i am facing here is why only website's response is not fetched? What is wrong with that? I have tried the above code with other website's url like google,yahoo and it works perfectly. This url is accessible in url. Please help me if i am missing anything important.

1 Answer 1

2

Since you don't enabled port forwarding, we can't take a look at the "content of your url".

However, I guess the there is a line of the response is this:

<?xml version="1.0" encoding="UTF=8" ?>

Or

<meta http-equiv="Content-Type" content="text/html; charset=UTF=8">

You have to change it to

<?xml version="1.0" encoding="UTF-8" ?>

Or

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

By changing, I mean: The webserver who servers the response (you set up by your own, for example XAMPP) is probably uploading an xml (or html) file. That file is the one with the wrong line.

Of course, UTF=8 doesn't exist. UTF-8 does.

Sign up to request clarification or add additional context in comments.

9 Comments

It is giving error already so how can i change the contents of url?. And how can i enable port forwarding?
No, you have to edit the file that the HttpServer uploads. I guess some kind of index.html.
Well, that i cannot do. Because i am not allowed to edit any content of the website. It is controlled by admin and i guess due to certain kind of security only i am not able to fetch the response.
Then contact the admin and tell him to change it.
@ankur.trapasiya As Martjin said, the content of the website has to be changed in order to work with the library you are using. If the content cannot be changed, then you either need to override the character set your library uses (so it does not try to interpret the tag) or fetch the content another way and modify it before decoding (e.g. fetch yourself using java.net.URL).
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.