Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:16:07+00:00 2026-06-11T08:16:07+00:00

When I send request from JSP I use this code <%@ page language=java contentType=text/html;

  • 0

When I send request from JSP I use this code

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<form method="post"  action="http://translate.intelsoft.az" id="tform" name="ftext">
<input class="gogo1"  value="a" name="l" id="l1" /> <div class="il">
<p>Rusca</p>
<textarea class="ilkin1" name="t" id="t1" >
выыававыавыавыавфыа
выыававыавыавыавфыа
выыававыавыавыавфыа
выыававыавыавыавфыа</textarea>
<div><input class="gogo" type="submit" value="Tərcümə1" name="b1" /></div></div>    </form>

</body>
</html> 

and the response is correct, so that I see my parameter’s value. But when I send from Java I get no correct response. I think that the parameters are not sent correctly. Here’s my Java code:

String urlParameters = "t=выыававыавыавыавфыа&l=a";
String request = "http://translate.intelsoft.az";
URL url = null;
try {
    url = new URL(request);
} catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} 
HttpURLConnection connection = null;
try {
    connection = (HttpURLConnection) url.openConnection();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}           
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setInstanceFollowRedirects(false); 
try {
    connection.setRequestMethod("POST");
} catch (ProtocolException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} 
connection.setRequestProperty("Content-Type", "text/html"); 
connection.setRequestProperty("charset", "utf-8");
connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
connection.setUseCaches (false);

DataOutputStream wr;
try {
    wr = new DataOutputStream(connection.getOutputStream ());
    wr.writeBytes(urlParameters);
    wr.flush();

    BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    String line;
    while ((line = rd.readLine()) != null) {
        System.out.println(line);
    }
    wr.close();





    connection.disconnect();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

What is wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:16:09+00:00Added an answer on June 11, 2026 at 8:16 am

    First, your JSP page is using UTF-8 character encoding.

    <%@ page ... pageEncoding="UTF-8"%>
    

    However, your Java code isn’t using the same character encoding.

    DataOutputStream wr;
    try {
        wr = new DataOutputStream(connection.getOutputStream ());
        wr.writeBytes(urlParameters); // <--- Wrong! Uses platform default encoding.
        wr.flush();
    

    You need to replace that troublesome piece by

    try {
        connection.getOutputStream().write(urlParameters.getBytes("UTF-8"));
    

    Note that the whole DataOutputStream decoration is unnecessary. It serves an entirely different purpose (namely writing of .dat type files). Don’t forget to specify the same charset in the way how you’ve set your Content-Length header.


    Second, the parameter names/values themselves should be URL-encoded in order to be extracted properly form the HTTP request.

    String urlParameters = "t=" + URLEncoder.encode("выыававыавыавыавфыа", "UTF-8")
                         + "&l=" + URLEncoder.encode("a", "UTF-8");
    

    Third, your request headers are actually also wrong:

    connection.setRequestProperty("Content-Type", "text/html"); 
    connection.setRequestProperty("charset", "utf-8");
    

    You aren’t sending text/html data at all. You are sending application/x-www-form-urlencoded data. Also, that charset should have been an attribute of the Content-Type header, thus so:

    connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
    

    See also:

    • Using java.net.URLConnection to fire and handle HTTP requests
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<input type=text name=designation value=<%=request.getParameter(designation)%> ></input> In this JSP, I've send request parameters from an
I want to send array of my own objects to JSP page by request.
I have used the following code to post a request to another jsp page
Here is the HTML from my .jsp page: <tr> <td><input type=checkbox name=<%=editID%>COM /> </td>
When I send a request from JSP FORM, the server side automatically parses data
I hosted a jsp service to access a java class to send a request
I want to send request to a servlet MyServlet from a JSP MyJsp.jsp ,
when using http post with flash that send ip address request from client computer
I need to send a http post request from my android device to a
Trying to find a way to send a POST HTTPS request from Python to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.