|
Hey guys i have got this code together for someone to log into a link and i need help finishing it off
any ideas why it won't login will output the message WORK IN PROGRESS meaning wrong credentials any help?
package com.domain.app;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.os.NetworkOnMainThreadException;
import android.os.StrictMode;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
@SuppressLint("NewApi")
public class ServerLogin extends Activity {
EditText un, pw;
TextView error;
Button ok;
@SuppressLint("NewApi")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_server_login);
if(Build.VERSION.SDK_INT >= 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
un = (EditText)findViewById(R.id.et_un);
pw = (EditText)findViewById(R.id.et_pw);
ok = (Button)findViewById(R.id.btn_login);
error = (TextView)findViewById(R.id.tv_error);
ok.setOnClickListener(new View.OnClickListener() {
@SuppressLint("NewApi")
<a href="/Members/override">@Override</a>
public void onClick(View v) {
String userName = un.getText().toString();
String passWord = pw.getText().toString();
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("username", un.getText().toString()));
postParameters.add(new BasicNameValuePair("password", pw.getText().toString()));
String response = null;
try {
response = CustomHttpClient.executeHttpPost("http://www.domain.com/Launcherloginaccount.php?username="+ userName +"&password="+ passWord +"", postParameters);
String res = response.toString();
res = res.replaceAll("\\s+","");
if(res.equals("1"))
Toast.makeText(getBaseContext(), "HOLY F*** IT WORKED YOU LOGGED in :D", Toast.LENGTH_SHORT).show();
else
Toast.makeText(getBaseContext(), "WORK IN PROGRESS", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
un.setText(e.toString());
}
}
});
}
}
|
|
|
|
|
What is the actual value of response on return from the call to CustomHttpClient.executeHttpPost ? And why are you calling toString() on a String value?
Use the best guess
|
|
|
|
|
toString because un and pw are EditText
|
|
|
|
|
String response = null;
try {
response = CustomHttpClient.executeHttpPost("http://www.domain.com/Launcherloginaccount.php?username="+ userName +"&password="+ passWord +"", postParameters);
String res = response.toString();
response is already a String .
Use the best guess
|
|
|
|
|
Been fixed i just need help with logging into an XML array and having it display the data
|
|
|
|
|
Member 10160291 wrote: logging into an XML array What does that mean?
Use the best guess
|
|
|
|
|
<account>
<user>
<Username>Error</Username>
<Cash>Error</Cash>
<Bank>Error</Bank>
<Job>Error</Job>
<Inventory/>
<Weapons/>
<Role>Error</Role>
<Holster>Error</Holster>
<Bag>Error</Bag>
<Jail>Error</Jail>
<Playtime>01:36:01</Playtime>
<DOB>1/1/2000</DOB>
<licences/>
<skills>
<Strength>0</Strength>
<Mining>0</Mining>
<Vehicle>0</Vehicle>
<Gathering>0</Gathering>
<Air>0</Air>
<Unit>0</Unit>
</skills>
</user>
<vehicles>
<vehicle>
<key>Error</key>
<storage>True</storage>
<cost>Error</cost>
<sell>Error</sell>
<tuneup>Error</tuneup>
<turbo>Error</turbo>
<lowjacksell>Error</lowjacksell>
<alarm>Error</alarm>
<plate>Error</plate>
</vehicle>
</vehicles>
<shops>
<shop>
<name>Error</name>
<stock>[["Stock",0]]</stock>
<takings>Error</takings>
<value>Error</value>
</shop>
</shops>
<crimedatabase>
<log>
<citizen>Error</citizen>
<reporttype>PR</reporttype>
<crimes>
<crime>
<ticket>Error</ticket>
<suspect>Error</suspect>
<records/>
</crime>
</crimes>
</log>
</crimedatabase>
<dmv>
<vehicleonmap>
<log>
<vehicle>
<id>0</id>
<owner>Error</owner>
<key>Error</key>
<plate>Error</plate>
</vehicle>
</log>
</vehicleonmap>
<vehiclestorage>
<log>
<vehicle>
<id>0</id>
<owner>Error</owner>
<key>Error</key>
<plate>Error</plate>
</vehicle>
</log>
</vehiclestorage>
<licencelist>
<log>
<Player>Error</Player>
<DriverLic>0</DriverLic>
<BoatLic>0</BoatLic>
<PilotLic>0</PilotLic>
<PistolLic>0</PistolLic>
<RifleLic>0</RifleLic>
<MotorLic>0</MotorLic>
<Passport>0</Passport>
<TruckLic>0</TruckLic>
</log>
</licencelist>
</dmv>
</account>
|
|
|
|
|
You really need to spend some more time writing down a detailed explanation of your problem. The listing of some XML on its own means absolutely nothing.
Use the best guess
|
|
|
|
|
The issue is i have a login system all worked out i just need it so once a user has logged in they can they be taken to the formatted XML Array with all the users data to display for interest
The issue that im having is being able to have the XML generate on login
|
|
|
|
|
Hi,
i want to convert a cmyk type image into RGB Image.
if i use the below code the conversion happens but the image is not displaying properly.i can see block strike-through codes in my output image. any other way to convert CMYK to RGB.
java.util.Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName("JPEG");
ImageReader reader = null;
while(readers.hasNext()) {
reader = (ImageReader)readers.next();
if(reader.canReadRaster()) {
break;
}
}
ImageInputStream input = ImageIO.createImageInputStream(fromFile);
reader.setInput(input);
Raster raster = reader.readRaster(0, null);
BufferedImage bi = new BufferedImage(raster.getWidth(), raster.getHeight(),BufferedImage.TYPE_INT_RGB);
bi.getRaster().setRect(raster);
System.out.println("\n\n\n bi.getColorModel().getColorSpace().getType()\n\n "+bi.getColorModel().getColorSpace().getType());
int colorSpaceType = bi.getColorModel().getColorSpace().getType();
if( colorSpaceType == ColorSpace.TYPE_CMYK)
{
System.out.println("\n\n\n is CMYK image \n\n\n");
}
else if(colorSpaceType == ColorSpace.TYPE_RGB)
{
System.out.println("\n\n\n is RGB image \n\n\n");
ImageIO.write(bi, "JPEG", new File("d:\\hi.jpg"));
}
|
|
|
|
|
how to draw smooth curve with java?
|
|
|
|
|
|
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.awt.event.*;
import java.net.*;
import javazoom.jl.player.*;
class Myjpanel extends JPanel implements ActionListener,Runnable
{
boolean count=true;
Thread th;
JSlider js1;
JLabel jl;
private JButton jb1,jb2;
JTextField jt1;
public SoundJLayer soundToPlay;
public Myjpanel()
{
jl=new JLabel(" ");
jb1=new JButton("Open");
jb2=new JButton("Stop");
jt1=new JTextField(20);
js1=new JSlider(1,100);
add(jt1);
this.add(jb1);
this.add(jb2);
add(js1);
js1.setValue(0);
js1.setPaintLabels(false);
jb1.addActionListener(this);
jb2.addActionListener(this);
this.add(jl);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==jb2)
{
count=true;
soundToPlay.stop1();
jl.setText(" 0 : 0 ");
}
else
{
th=new Thread(this);
if(count==true)
{
JFileChooser jfc=new JFileChooser();
File f=null;
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
int choice=jfc.showOpenDialog(null);
if(choice!=JFileChooser.CANCEL_OPTION)
{
f=jfc.getSelectedFile();
}
if(f==null)
JOptionPane.showMessageDialog(null,"You didn't select a file");
else
{
int option=JOptionPane.showConfirmDialog(null,"You selected "+f.getName()+"\nDo you want to open it?");
if(option==JOptionPane.YES_OPTION)
{
String str=f.getName();
jt1.setText(str);
soundToPlay= new SoundJLayer(f);
soundToPlay.play();
th.start();
count=false;
}
}
}
}
}
public void run()
{
int i=0;
for(;count==false;)
{
try
{
Thread.sleep(1000);
}
catch(InterruptedException ex)
{
}
double db1=soundToPlay.player.getPosition();
int db=(int)db1/1000;
js1.setValue(db);
db=db%60;
if(db==59)
i++;
String str1=String.valueOf(i);
String str=String.valueOf(db);
jl.setText(str1+" : "+str);
}
}
}
class Myjframe extends JFrame
{
private Myjpanel jp;
public Myjframe(String title)
{
super(title);
jp=new Myjpanel();
Container ct=getContentPane();
ct.add(jp);
setVisible(true);
setBounds(50,50,200,200);
setDefaultCloseOperation
(JFrame.EXIT_ON_CLOSE);
}
}
public class mymp3player2
{
public static void main(String[] args)
{
Myjframe obj=new Myjframe("Sumit's");
}
}
class SoundJLayer implements Runnable
{
public Player player;
public Thread playerThread;
private URL url;
public SoundJLayer(File file)
{
try
{
url=file.toURL();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public void play()
{
try
{
InputStream ip=url.openStream();
this.player = new Player(ip);
this.playerThread = new Thread(this, "AudioPlayerThread");
this.playerThread.start();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public void run()
{
try
{
this.player.play();
}
catch (javazoom.jl.decoder.JavaLayerException ex)
{
ex.printStackTrace();
}
}
public void stop1()
{
this.player.close();
}
}
|
|
|
|
|
1. Pleas indent your code and put it between <pre> tags for readability, thus
public void stop1()
{
this.player.close();
}
2. Give proper details of your problem.
Use the best guess
|
|
|
|
|
when i play an mp3 file then if i want to pause that song for some time then i can't i can only play and stop the song in this code
|
|
|
|
|
Rather than just repeating your original post, it would be helpful if you followed my previous suggestions. It is extremely difficult to read your code from that unformatted listing, and I cannot find a method anywhere that handles a Pause command.
Use the best guess
|
|
|
|
|
I'm getting two values for my salt
This is my code
private static String getSalt() throws NoSuchAlgorithmException, NoSuchProviderException
{
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
byte[] salt = new byte[8192];
sr.nextBytes(salt);
return salt.toString();
}
and when I save it in my database
my code
PS.setString(1, User);
PS.setString(2, getSalt());
PS.executeUpdate();
System.out.println(" Salt :"+getSalt());
I get different value..why?
I'm salting String asdf
Database value [B@2fc396df
Printed value [B@5199c9ac
|
|
|
|
|
salt.toString();
That doesn't do what you think it does. It prints the object reference not the contents.
|
|
|
|
|
By the way, your function createSalt() creates a new salt every time you call it!
When you want to compare the original value and the database value, you hat to write the salt into a variable, then set it to your object, write to database, then retrieve from the database.
|
|
|
|
|
public void run(){
for(int i=0;i<totalThread;++i){
Thread x=new Thread(new RequestProcessor(documentRootDirectory,indexfileName));
x.start();
}
System.out.println("coonection accepted"+server.getLocalPort());
System.out.println("Dokumen root"+documentRootDirectory);
while(true){
try{
Socket request=server.accept();
RequestProcessor.startProcessing();
}
catch(IOException ex){
}
}
}
error message from this program : method RequestProcessor can't not implemented with given types,
althaugh i have create class RequestProcessor from one package, can you help me to integrated the totalThread with RequestProcessor? the error start when i try to instance new Thread.
thx.
|
|
|
|
|
|
How to read this XML file:
I need to read attribute name/value pair and element contents.
="1.0"="UTF-8"
<idmef:IDMEF-Message xmlns:idmef="http://iana.org/idmef" version="1.0">
<idmef:Alert messageid="abc123456789">
<idmef:Analyzer analyzerid="bc-sensor01">
<idmef:Node category="dns">
<idmef:name>sensor.example.com</idmef:name>
</idmef:Node>
</idmef:Analyzer>
<idmef:CreateTime ntpstamp="0xbc71f4f5.0xef449129">2000-03-09T10:01:25.93464Z</idmef:CreateTime>
<idmef:Source ident="a1a2" spoofed="yes">
<idmef:Node ident="a1a2-1">
<idmef:Address ident="a1a2-2" category="ipv4-addr">
<idmef:address>192.0.2.200</idmef:address>
</idmef:Address>
</idmef:Node>
</idmef:Source>
<idmef:Target ident="b3b4">
<idmef:Node>
<idmef:Address ident="b3b4-1" category="ipv4-addr">
<idmef:address>192.0.2.50</idmef:address>
</idmef:Address>
</idmef:Node>
</idmef:Target>
<idmef:Target ident="c5c6">
<idmef:Node ident="c5c6-1" category="nisplus">
<idmef:name>lollipop</idmef:name>
</idmef:Node>
</idmef:Target>
<idmef:Target ident="d7d8">
<idmef:Node ident="d7d8-1">
<idmef:location>Cabinet B10</idmef:location>
<idmef:name>Cisco.router.b10</idmef:name>
</idmef:Node>
</idmef:Target>
<idmef:Classification text="Ping-of-death detected">
<idmef:Reference origin="cve">
<idmef:name>CVE-1999-128</idmef:name>
<idmef:url>http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-1999-128</idmef:url>
</idmef:Reference>
</idmef:Classification>
</idmef:Alert>
</idmef:IDMEF-Message>
|
|
|
|
|
I showed you how to find information on reading CSV files, no doubt you can do the same for XML.
Use the best guess
|
|
|
|
|
I know how to read xml file but I have a problem with this file.
|
|
|
|
|
peniya wrote: I know how to read xml file but I have a problem with this file. Then you need to explain what that problem is; please don't expect people to guess it.
Use the best guess
|
|
|
|