How can i login to a website using java
hi,
i tried to write a java program to which will take username and password and login to a given site. but some how its not working. i am actually trying to login to the follwoing website:
https://roundup.ffmpeg.org/roundup/ffmpeg/
can anyone provide some example program to login to this website.
br
mahbubul-syeed
Hi,
i am really sorry... but i am new in this forum and i did not know this. here is my code that i have written. it did not show any error and displays the content of the page but did not logged in. please give your comment.. i badly need a solution.
package myUtility_files;
import java.net.*;
import java.io.*;
public class LogInByHttpPost {
//private static final String POST_CONTENT_TYPE = "application/x-www-form-urlencoded";
private static final String LOGIN_ACTION_NAME = "submit";
private static final String LOGIN_USER_NAME_PARAMETER_NAME = "__login_name";
private static final String LOGIN_PASSWORD_PARAMETER_NAME = "__login_password";
private static final String LOGIN_USER_NAME = "mahbubul";
private static final String LOGIN_PASSWORD = "mahbubul007";
private static final String TARGET_URL = "http://roundup.ffmpeg.org/roundup/ffmpeg/";
public static void main (String args[])
LogInByHttpPost httpUrlBasicAuthentication = new LogInByHttpPost();
httpUrlBasicAuthentication.httpPostLogin();
public void httpPostLogin ()
try
// Prepare the content to be written
// throws UnsupportedEncodingException
String urlEncodedContent = preparePostContent(LOGIN_USER_NAME, LOGIN_PASSWORD);
HttpURLConnection urlConnection = doHttpPost(TARGET_URL, urlEncodedContent);
//String response = readResponse(urlConnection);
System.out.println("Successfully made the HTPP POST.");
//System.out.println("Recevied response is: '/n" + response + "'");
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
catch(IOException ioException)
ioException.printStackTrace();
System.out.println("Problems encounterd.");
private String preparePostContent(String loginUserName, String loginPassword) throws UnsupportedEncodingException
// Encode the user name and password to UTF-8 encoding standard
// throws UnsupportedEncodingException
String encodedLoginUserName = URLEncoder.encode(loginUserName, "UTF-8");
String encodedLoginPassword = URLEncoder.encode(loginPassword, "UTF-8");
String content = "login=" + LOGIN_ACTION_NAME +" &" + LOGIN_USER_NAME_PARAMETER_NAME +"="
+ encodedLoginUserName + "&" + LOGIN_PASSWORD_PARAMETER_NAME + "=" + encodedLoginPassword;
return content;
public HttpURLConnection doHttpPost(String targetUrl, String content) throws IOException
HttpURLConnection urlConnection = null;
DataOutputStream dataOutputStream = null;
try
// Open a connection to the target URL
// throws IOException
urlConnection = (HttpURLConnection)(new URL(targetUrl).openConnection());
// Specifying that we intend to use this connection for input
urlConnection.setDoInput(true);
// Specifying that we intend to use this connection for output
urlConnection.setDoOutput(true);
// Specifying the content type of our post
//urlConnection.setRequestProperty("Content-Type", POST_CONTENT_TYPE);
// Specifying the method of HTTP request which is POST
// throws ProtocolException
urlConnection.setRequestMethod("POST");
// Prepare an output stream for writing data to the HTTP connection
// throws IOException
dataOutputStream = new DataOutputStream(urlConnection.getOutputStream());
// throws IOException
dataOutputStream.writeBytes(content);
dataOutputStream.flush();
dataOutputStream.close();
return urlConnection;
catch(IOException ioException)
System.out.println("I/O problems while trying to do a HTTP post.");
ioException.printStackTrace();
// Good practice: clean up the connections and streams
// to free up any resources if possible
if (dataOutputStream != null)
try
dataOutputStream.close();
catch(Throwable ignore)
// Cannot do anything about problems while
// trying to clean up. Just ignore
if (urlConnection != null)
urlConnection.disconnect();
// throw the exception so that the caller is aware that
// there was some problems
throw ioException;
br
mahbubul-syeed
Edited by: mahbubul-syeed on Jun 11, 2009 5:07 AM
Similar Messages
-
How can an email account be created using Java mail on the FLY.
Scenario is such that i am using mail server from MDaemon.com and JavaMail api,and making Email website like yahoo...some what ! but how can a user create his account by just filling the form and when he enters his account be created in Mail server..
Last time I checked MDaemon has its own API for account management. I have never tried to do anything with it but their sales literature says it exists.
Account management will be specific to the platform and mail server software. This is beyond the scope of JavaMail which is for message transport (and management to an extent on IMAP servers), not account management on the server.
The other alternative is to write your own application that modifies the structures used by mdaemon but since it already has an API why bother. -
How can i digital sign a file using JAVA?
and how can i verify the digitially signed file was not altered by anyone using JAVA?
please provide me with the simpliest way to do this.
thanks a lot.I have no idea but you might want to take a look at :
http://java.sun.com/j2se/1.5.0/docs/guide/security/index.html
hth -
How can I open/save .xlsx file using java
Hi
I have a jsp whose contenttype of response is application/vnd.ms-excel.
When I am saving the file as .xlsx and opening from disk it displays error message.
How can I save and/or open the file as .xlsx?
Any advice will be appreciated.
Thanks
Rohini Kumar Jsunshine_vennela wrote:
I have a jsp whose contenttype of response is application/vnd.ms-excel.That's not the way to create excel files. You're just creating a plain vanilla HTML file and fooling the browser with a wrong content type.
Checkout the Apache POI XSSF API or the OpenXML4J API's to create xlsx files and use a servlet to write it to the outputstream. -
How can I get selected EXCEL area using java script office API (v 1.0)
Hello everyone,
I need to get values of specified area in an excel sheet using java Script Office API. For an example,
A1:A7 row load into array using JS.And you posted to a C++ forum, not a JavaScript or Excel forum.... why?
Visual C++ MVP -
How can I login to a website from LabVIEW, for example to Hotmail ?
I'd like to use the Data Socket Write VI to be able to give my
loginname and my password from LabVIEW 6i. I really don't know how
this VI works, and/or if this is possible.
Thanks for your help.Hello,
Thank you for your inquiry regarding website login. I understand that you would like to logon to Hotmail using LabVIEW 6.i. DataSocket however, is used to send and receive data between computers running LabVIEW. One possible solution is to use ActiveX events to run an internet browser window on the front panel of your VI. I assume however, that you would like LabVIEW to automate this task. Unfortunately Hotmail is a secure site using Microsoft Passport .NET. .NET is supported by LabVIEW 7.0 but the .NET control of Passport would have to be provided by Microsoft. The following link is a great resource to learn more about the .NET single-login system.
http://msdn.microsoft.com/msdnmag/issues/02/09/Passport/
I hope this resource helps. Let me know if you wo
uld like more help using a browser window on your front panel using ActiveX.
Shea C.
Applications Engineering -
How can I make an updatable website using Adobe?
Hello,
I am looking to create a website to host my YouTube videos, photographs, other information and a blog, and possibly an online store in the future. I don't know where to begin with this because I'm not sure how easy websites are to update once they have been uploaded (unless you use an online website maker).
Could someone please advise me on what software I should use (I have created a business website for someone using Muse in the past but it doesn't need regular updating), and also how I should have the website hosted?
Many thanks,
RyanAsk in the iWorks forum here:
https://discussions.apple.com/community/iwork -
How can I query a https website used to display the status of an application using Powershell?
Need assistance on querying the status of an application using Powershell. The status of the application is displayed in a https website. I want to receive a notification when one of the listed applications fails.
Below is an example the failures I need to capture.
h-t-t-p-::://xpps2.xxcom/ssol/sSOLStatus.asp?autorun
SSOL Status
Current App Server: xpps2.xx.com
SQL Server Details:
SSS_MyAccount DB Connection: PASS
SSS_MyAccount DB Query: PASS
CAGWEB DB Connection: FAIL - Unable to Connect
CAGWEB DB Query: FAIL - Pay location not found
DB2 Server Details:
DB2 D Connection: PASS
DB2 Q Query: FAIL -Acct not found
DB2 X Query: PASS
DB2 N Query: PASS
DB2 S Query: PASS
DB2 K Query: PASS
DB2 I Query: PASS
Mitem Server Details:
MITEM server: MITEMP2
MITEM Total Devices: 10
MITEM Devices Lines Up: 10
MITEM Devices Logged In: 10
MITEM Devices In Use: 0
Mitem Server Status: PASS
Web Service Details:
SAW Web Service Status: FAIL
Maximo Vizcainothats where you are going to check what it is supposed to be.
lets say your page shows as SSOL Status : running you
probably want to use "if($totalstrng.ToLower().contains("ssqlL status
: running"))". its
checking if the html page contains the string you are looking for.
you might want to print $totalstrng
and see what you need to look for.
usign XMLHttp
or XML object as mentioned by JRV might be easier and faster way. -
How can i send the chinese sms using java J2EE(web application)
hi,
i have the difficulty on sending chinese sms using J2EE application.i try to input the chinese word to jsp and send the plain text sms. i received the sms with plenty of question mark "?????". i think it is regarding to the conversion of String to some kind of format that supported by mobile phone. below are some code the send the sms to recipient. i need someone help in order to have the solution.
thanks a lot
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="se.sapio.rta.service.MPMService"%>
<%@ page import="java.util.Locale"%>
<%
Locale.setDefault(Locale.UK);
Context ctx;
MPMService mpmservice;
ctx = new InitialContext();
mpmservice = (MPMService) ctx.lookup("BC/Service/RTAMPM");
LSUser user = null;
boolean ok = true;
try {
if (ok) {
String sender = request.getParameter("sender");
String phonenr = request.getParameter("phonenr");
String sendmsg = request.getParameter("sendmsg");
if(bError) {
byte[] bytes = message.getBytes("UTF-8");
message = mobileclientservice.ByteEncode(bytes);
response.sendRedirect("send_sms.jsp?s="+request.getParameter("s")+"&msg="+message+"&phonenr="+request.getParameter("phonenr").replaceAll("\\+","%2B")+"&sender="+request.getParameter("sender")+"&sendmsg="+request.getParameter("sendmsg").replaceAll("\\+","%2B"));
String resp = "";
if(mpmservice.sendPlainTextSMS(sender, phonenr, sendmsg)) {
resp=mpmservice.getLang(user.getLang(), "sms_sent");
} else {
resp=mpmservice.getLang(user.getLang(), "sms_not_sent");
} %>
<jsp:include page="/top.jsp" />
<p class="headline"><%=mpmservice.getLang(user.getLang(), "send_sms_title")%></p>
<form name="operatordetails" id="operatordetails" method="post" action="send_sms.jsp">
<INPUT TYPE=hidden NAME=s VALUE="<%=request.getParameter("s")%>">
<INPUT TYPE=hidden NAME=phonenr VALUE="<%=request.getParameter("phonenr")%>">
<table class="infotable" id="report">
<tr>
<td class="left" colspan="2"><%=resp%></td>
<td class="right"></td>
</tr>
<tr>
<td class="left" colspan="2">
<input class="halfmiddle" name="Back" type="submit" id="Back" value="<%=mpmservice.getLang(user.getLang(), "back")%>" />
</td>
<td class="right"> </td>
</tr>
</table>
</form>
<jsp:include page="/bottom.jsp" />
<% } %>
public boolean sendPlainTextSMS(String sender, String recipient, String sendmsg){
if(recipient.charAt(0) == '+')
recipient = recipient.substring(1);
String senderIdType = "Alpha";
if( (sender.charAt(0) >= '0' && sender.charAt(0) <= '9') || sender.charAt(0) == '+')
senderIdType = "Numeric";
if(sender.charAt(0) == '+')
sender = sender.substring(1);
for(int i=0; i < sender.length(); i++)
if(!(sender.charAt(i) >= '0' && sender.charAt(i) <= '9'))
senderIdType = "Alpha";
log.warn("sending sms to: "+recipient + " sendtype: " + senderIdType + " msg: "+ sendmsg);
log.warn("Encoded sms:"+Encode(sendmsg));
try{
String postData = "XMLDATA=" + URLEncoder.encode("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\r\n" +
"<NotificationRequest Version=\"3.4\">\r\n" +
" <NotificationHeader>\r\n" +
" <PartnerName>" + SMS_PARTNER_NAME + "</PartnerName>\r\n" +
" <PartnerPassword>" + SMS_PARTNER_PASSWORD + "</PartnerPassword>\r\n" +
" <SubscriptionName>XML</SubscriptionName>\r\n" +
" </NotificationHeader>\r\n" +
" <NotificationList BatchID=\"1\">\r\n" +
" <Notification SequenceNumber=\"0\" MessageType=\"SMS\">\r\n" +
" <Message>" + Encode(sendmsg) + "</Message>\r\n" +
" <Profile>" + SMS_PARTNER_PROFILE + "</Profile>\r\n" +
" <SenderID Type=\"" + senderIdType + "\">" + sender + "</SenderID>\r\n" +
" <Subscriber>\r\n" +
" <SubscriberNumber>" + recipient + "</SubscriberNumber>\r\n" +
" </Subscriber>\r\n" +
" </Notification>\r\n" +
" </NotificationList>\r\n" +
"</NotificationRequest>","ISO-8859-1");
appreciate for anyone provide the solution.
thanks a lotHi,
I want to send sms from web application to mobile phones at the time of registration. Its verymuch greatful to me, if you let me know, how to send from jsp to mobile. because from your post, i got, you already know about sending sms from jsp to mobile.
please let me know, how to send sms
[email protected]
Thanks in advance for your kind help -
How can I connect to a database using Java Web Start?
When I run the application without Java Web Start, the program can get the driver and connect to the database. However, when I try to use this same application with Java Web Start, the program can not load the driver. Why is this happening? I am using a mySql database driver.
I assume you are trying to connect using JDBC, are did you include the jdbc jar in your resources ?
-
How can i rename a jar file using only java code
i have tried everything i can think of to accomplish this but nothing works.
ghostbust555 wrote:
In case you geniuses haven't realized I said I tried everything I can think of not that I tried everything. So help or shut up I realize that I didn't try everything but if you can't figure it out either DO NOT POST.
And the question is how can i rename a jar file using java code? As it says in the title. Read.I would tell you to use the File.renameTo method, but surely that would have been obvious, and you would have tried it already? But maybe you didn't. You were kind of lacking in details in what you tried.
And yes, I am a genius. Just don't confuse "genius" with "mind-reader". -
i want to use firefox to login a website ,in the same window and different tags can user the same session
but when i open other window and login the same website use different account .
how can i achieve it ? thinksYour problem has nothing to do with the faults or limitations of a web browser.
''There can be only ONE active user logged in on a specific website during a whole Browsing Session. Even if you try to log-in using a new window it will sign-out the earlier User ID from that website. It will keep the most recent logged-in User ID active.''
This is the general policy on which all websites are built. Even if you try to login the same website from another web browser, you won't be able to login from the second platform either. I just check it. Tried on Mozilla and Internet Explorer. -
Firewall stops Firefox from loading any websites... had to switch off security to send this message... How can I fix this? Am using Symantec Client Firewall
This forum is only for discussions on the forums themselves. You should post your question in the apropriate product forum,
http://forums.adobe.com/community/shockwave
if your ptoblem is with Shockwave, or
http://forums.adobe.com/community/flashplayer
if it affects Flash Player. -
How can I login and retrieve my user file from the trash?
I was trying to find out where all my HD had gone, which a did using ‘What Size’.
I found what looked like an old backup file so I put the file in the trash.
It turns out that the file was my user file. So now I can’t login to as the user.
How can I login and retrieve my user file from the trash?The Digital Editions forum is here, in case this is what you are talking about:
http://forums.adobe.com/community/adobe_digital_editions
If you are not, I apologize for the misunderstanding. -
How can we get ADFSecurity work when used in OC4J, OID and OAM?
I am getting error in http server log "mod_oc4j: Response status=499 and reason=Oracle SSO, but failed to get mod_osso global context."
But I am not using Oracle SSO and my client doesn't want to use it either, I am using OAM SSO(CoreIDSSO) in my configuration. Please read the details below.
I am using ADFSecurity in an app that is protected by OAM. To migrate ADFSecurity permissions from
system-jazn-data.xml to OID, I used JAZNMigrationTool to populate OID with Grantees and Permissions. OAM gives login page, and authentication works fine.
But ADFSecurity is not working. ADFComponent Delete button is enabled even for roles that dont have permissions for the iterator delete.
- The app works fine when I use without OAM. ADF Security permissions work fine.
- The app works fine when used with OAM, but with ADFSecurity disabled (enforce=false).
- When I enforce ADFSecurity alongwith OAM, ADFSecurity is not working.
In the doc "Oracle Containers for J2EE Security Guide b28957", there is a mention of use of CoreIDPrincipal for permissions. Our OID Permissions entries show
LDAPRealmRole for attribute orcljaznprincipal. I am not sure if this could be the reason.
We have configured AccessServerSDK for the SOA instance and have policy for the urls in the policy manager. We have entries in orion-application.xml, orion-web.xml and system-jazn-data.xml as per the documentations.
How can we get ADFSecurity work when used with OID and OAM?Have you been able to successfully integrate OAS with OAM & OID? We have similar requriement and so far we have not been able to get it working.
We have application specific roles which we map to OID roles using orion-application.xml.
Any pointers to achieve this would be greatly appreciated.
thanks,
Dipal
Maybe you are looking for
-
My itunes account is messed up. How can I restore my playlist folders in itunes? The list's are there but the individual song titles aren't. They are only listed by album. I can only see the song titles as they are played at the top of my itunes. Thi
-
OTF formatted Spool and ABAP spool to be merged into a pdf
I am creating a program which merges two spools into one pdf document. Now, the two spools are different, one is in otf format since its a SAP script. Other is a ABAP list. I use function modules CONVERT_ABAPSPOOLJOB_2_PDF & CONVERT_OTFSPOOLJOB_2_PDF
-
Hey all, I have a ten day old N96 but have some issues about its display. There are about three shiny dots on the display. One of them at about the center and a bit shiny and unpleasant specially in dark colors. Two others are at about the corners bu
-
New updater fouled my 60 gb video Ipod
Video plays (any of my videos) for about 20 secs then freezes, after about 15 seconds continues but with no audio. Have reset and restore, doesn't help. This started inmediately after using the new updater, anybody know a fix? AMD 2.4 Ghz Windows X
-
No sound from any email i open
Since upgrading to ML i am not able to hear any sound when opening email attatchments IE WMV files or anything