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 8737941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:38:03+00:00 2026-06-13T10:38:03+00:00

I am trying to write a java program that will allow me to send

  • 0

I am trying to write a java program that will allow me to send a post command to a website rather than actually having to fill out a form myself. The current code I have right now is not working however and only returning a response code of 200. It obviously should be submitting and moving onto the next page, but it isn’t based on the response code. The form html is:

<div id="email" class="required"><label for="email" >Email Address</label><input  name="email"  value=""  /></div><div id="keyword" class="required"><label for="keyword" >Weekly Keyword</label><input  name="keyword"  value=""  /></div><div id="login" class="required"><label for="login" ></label><input type="image" src="public/images/btn_enter_now.png" name="login" value="Login" /></div>

The code I have written so far is as follows:

import javax.net.ssl.HttpsURLConnection;
   import javax.net.ssl.SSLContext;
   import javax.net.ssl.TrustManager;
   import javax.net.ssl.X509TrustManager;
   import java.security.cert.X509Certificate;  
    import java.io.*;
   import java.net.*;
    import javax.net.ssl.*;
    import java.security.*;


   public class CssAttack {

         public static void test() throws NoSuchAlgorithmException, KeyManagementException {
         TrustManager trm = new X509TrustManager() {
               public X509Certificate[] getAcceptedIssuers() {
                  return null;
               }

               public void checkClientTrusted(X509Certificate[] certs, String authType) {

               }

               public void checkServerTrusted(X509Certificate[] certs, String authType) {
               }
            };

         SSLContext sc = SSLContext.getInstance("SSL");
         sc.init(null, new TrustManager[] { trm }, null);
         HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
      }


      public static void main(String[] args) throws IOException {
            try{
                test();
         }
            catch(Exception e){

            }


         String httpsURL = "website";

         String query = "email="+URLEncoder.encode("blah@blah.com","UTF-8"); 
         query += "&";
         query += "keyword="+URLEncoder.encode("PRETZEL","UTF-8");
            query += "&";
            query += "login="+URLEncoder.encode("Login","UTF-8");

         URL myurl = new URL(httpsURL);
         HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
         con.setRequestMethod("POST");

         con.setRequestProperty("Content-length", String.valueOf(query.length())); 
         con.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); 
         con.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0;Windows98;DigExt)"); 
         con.setDoOutput(true); 
         con.setDoInput(true); 

         DataOutputStream output = new DataOutputStream(con.getOutputStream());  


         output.writeBytes(query);

         output.close();

         DataInputStream input = new DataInputStream( con.getInputStream() );  

         System.out.println("Resp Code:"+con .getResponseCode()); 
         System.out.println("Resp Message:"+ con .getResponseMessage()); 
      }
    }
  • 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-13T10:38:04+00:00Added an answer on June 13, 2026 at 10:38 am

    Check the class HttpUrlConnection.

    You can check the following question for a short example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a java program that will automatically download and name
I am trying to write a program that will send GPS coordinates using telnet.
I am trying to write a small java program that will accept a file
I'm trying to write a Java program that will run an OpenOffice Macro. I'm
I am trying at write a java program that hits a url over ssl,
I am trying to write a Java program that reads an input file consisting
I'm trying to follow Java's JDBC tutorials to write a Java program that can
I'm trying to write a program in Java that uses osql to generate a
I'm trying to write a program in Java that looks for patterns of strings
I am trying to write a Java program or Hadoop Pig script which will

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.