Methods To Get User Info Like Age / Email Address?
Oct 28, 2014how should i write appropriate methods to get user info like age, email address etc?
View Replieshow should i write appropriate methods to get user info like age, email address etc?
View Repliesi found a code to get emails from gmail in this forum.It's working very well, now i want to delete a specific sender email address.
So i can have the sender email with this:
Java Code: String senderAddress = aMessage.getFrom()[0].toString();
System.out.println(" From: " + senderAddress); mh_sh_highlight_all('java');
Now i want to do something like
Java Code: If (senderAddress = "test@gmail.com"){
message.setFlag(Flags.Flag.DELETED, true);
} mh_sh_highlight_all('java');
but it's not working.
I have two Strings
String TO = "raj@gmail.com;ra@gmail.com;RS@yahoo.com";
String CC= "rajt@in.com;rht@basss.com";
My query is i want to extract domains from above two Strings and Store these domains in HashSet. How could i do this with minimum code and performance wise.
I am a first-timer using J2EE and here on coderanch.com and wanted to make a Simple Email-like System which a Registered User can Send Message/Email to another Registered User. how to do it. I have already my register/login process done but I'm stuck on how to make the Email. And I have an sample Bootstrap for my UserInterface which I want to use.
View Replies View RelatedI am trying to invoke some methods in a for loop in order to print some info stored in a List. But for some reason, compiler pops a message saying "cannot find symbol - method getEmpID(). You are using a symbol here (a name for a variable, method or class) that has not been declared in any visible scope." But I am pretty sure that method getEmpID (as also getName(), getAfm(), and payment() ) have been declared as public.
Note: My List contains objects of different type (SalariedEmployee, HourlyEmployee). I hope this is not the factor causing this problem.
Java Code:
import java.util.*;
abstract class Employee{
private String name = "";
private String afm = "";
private long EmpID;
static long count=0;
[code]....
I having problem on validating email and password whether does it belongs to a registered members or not. I'm using NetBeans and created a database, table name as members. I have done setting up connection pool and fill in data to my members table.This is my members table data.
#|id|email|password|name
1|1|what@what.com|what|Number 1
2|2|fireup@fire.com|fire|Number 2
This is my index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Library Application</title>
[code]....
I need to track the client IP address from where user requested to my application.
I tried following:
request.getHeader("HTTP_X_FORWARDED_FOR"));
request.getHeader("X-Forwarded-For"));
request.getHeader("Proxy-Client-IP"));
request.getHeader("WL-Proxy-Client-IP"));
request.getHeader("HTTP_CLIENT_IP"));
request.getHeader("HTTP_X_FORWARDED_FOR"));
request.getRemoteAddr());
String ip = InetAddress.getLocalHost().getHostAddress();
In which InetAddress is giving my local machine IP when i run my application in localhost, but I mapped localhost:8080 with IIS server then InetAddress not giving exact IP address. How can we resolve this?
I want to ask how to track ip address and mac address of a different computer using java?
View Replies View RelatedI'm trying to build a program that will output what will ultimately look like a simple mario level turned on its side. As part of my output I need the user to define what mario looks like. I do this using Scanner and save the input to String mario. When I try to use that variable in another method it gives me troubles.
import java.util.Scanner;
public class Mario2
{
public static void mario() {
//user defines mario
String mario = ">->O";
Scanner keys = new Scanner(System.in);
System.out.println("What does mario look like?");
mario = keys.next();
System.out.println("Mario now looks like: " + mario);
[code]....
I will try to explain what i want to code , a HiLo game where the user can choose up to 3 different levels(1-10, 1-100, 1-1000) with these 3 methods
public static void main(String[] args) {...}
public static int playGame(int maxNumber) {...}
public static void giveResponse(int answer, int guess) {...}
with no Random , i will use the:
int number = (int)(Math.random() * max) +1; to generate numbers
I have tried so many times , but i don't get it ....
My code so far :
import java.util.Scanner;
public class HL{
public static void main(String[] args ){
Scanner s = new Scanner(System.in);
[Code] ....
I want to get info from one class to another LIKE ALL information.
View Replies View RelatedI'd like to know how to,
1. Connect to Google,
2. Search for something,
3. Return a SCREEN SHOT of the results.
I'm assuming this involves loading the webpage into a JFrame, or is there an easy workaround?
I am reading from a database(SQL Server 2012) and storing that information in a ResultSet. I am then trying to display that information using a DataTable.
Here is my managed bean
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package clientspage;
import java.io.Serializable;
[Code].....
The ID and the commandLinks are being displayed but the Client is not.
I was wondering where can I find info on how to grab info from websites to use in a program?
View Replies View RelatedI want to enter the triangle data in the method and every time I try to compile the program I get the error message--cannot find symbol.
import java.io.*;
import java.util.*;
public class trianglemethod {
public static void main(String [] args) {
Scanner kbreader = new Scanner (System.in);
[Code] .....
I want to ask that, when a server listen to A port and it accepts a request from a client then the server accepts the request using accept method,but how does the server get the info about the client like wat is the port no and ip address of the client,I read a answer regarding this that Server never gets the port no of client only the ip address and it connects to client using a connection stream but as far I know from networking, a device must have the ip address and port no of the device it wants to connect to.
View Replies View RelatedSuppose there're two classes: Exam and MainExam (contains a main method). class Exam has a constructor public Exam(String firstName, String lastName, int ID). Class MainExam reads data from a textfile. For example, the data can be: John Douglas 57. How can one pass data to the constructor from a textfile?
View Replies View RelatedLet's say I'd like to print out something as a prompt without end with a new line char, so the standard System.out.println() is not an option and I'd like to find something else inplace of println().
Where to find that? I googled about that and learned printf() is the one I want, but how to get it from java api documentation.
I was trying to make a UDP voice chat but i couldn't make the receive method work! so i just move on to work with TCP. I found a simple code that i found it pretty easy to understand,but i couldn't make it work, always stuck within exception.
Here is the output I got:
Available mixers:
Java Sound Audio Engine
Microsoft Sound Mapper
WinOS,waveOut,multi threaded
java.lang.IllegalArgumentException: Line unsupported: interface TargetDataLine supporting format PCM_SIGNED, 8000.0 Hz, 16 bit, mono, little-endian, audio data
And here is the code
sender:
Java Code:
package sender;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import javax.sound.sampled.AudioFormat;
[Code] ....
I tried to play with the index of mixerInfo array in the line
Java Code:
Mixer mixer = AudioSystem.getMixer(mixerInfo[1]); mh_sh_highlight_all('java');
But nothing happened. How I can fix that?
I've got a nasty nullpointer that I have tried to resolve to no avail as of yet. The program should prompt for a listings.txt file and take its info and write to a report file. Here's the stacktrace:
run:
Input file: listings
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.<init>(Writer.java:88)
at java.io.PrintWriter.<init>(PrintWriter.java:113)
at java.io.PrintWriter.<init>(PrintWriter.java:100)
at kettask2b.PropertyListingsReport.main(PropertyListingsReport.java:34)
Java Result: 1
Some adjustments that I have attempted are:
BufferedWriter pwfo = null;
for (int i = 0; i < args.length; i++) {
String string = args[i];
pwfo = null;
[Code] ....
Here's the code:
package kettask2b;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
[Code] ....
I am trying to add an email validator to my xhtml page, but I get this error:
<f:validateRegEx> Tag Library supports namespace: [URL] ...., but no tag was defined for name: validateRegEx
This is my code:
<h:inputText tabindex="7" styleClass="input" id="email" value="#{user.email}"
required="true" validatorMessage="Invalid email!">
<a4j:support id="emailRenderer" event="onblur"
reRender="emailPanel, errorPanel"
ajaxSingle="true"/>
<f:validateRegEx pattern="[w.-]*[a-zA-Z0-9_]@[w.-]*[a-zA-Z0-9].[a-zA-Z][a-zA-Z.]*(com|net|org|edu)" />
</h:inputText>
<p:message for="email" />
[Code] ....
I am trying send email .So I have downloaded javaEE and javamail jar files and added buildpath.And wrote this code below .But I am getting this exception.
Exception in thread "main" java.lang.RuntimeException: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbskV
534-5.7.14 ggcPi6MBZ4h8CCyCk2TG9EhiTGyE5MVBv7B3k7DsCldqjCuFvMTQG6aAbatrAWggH29muG
534-5.7.14 dzVh1kUYgMgNHAN558QRCnTjrNtUGv34Ul4pzUaansBuBfB0Kpz6_q7JTbrUuAmlZplouA
534-5.7.14 AHDXpFtuCkd-W17tHrZS5mqgVVxAcuKc-7TkhCDGShnfRBWU2R8v-gfvIQShszqsZmCl0i
[Code] .....
What am i missing here.
public static void main(String[] args) {
final String username = "mymail@gmail.com";
final String password = "mypass";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
[Code] .....
This is the program i tried
package com.readAlerts;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
[Code]...
But I am getting below error:
Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587;
nested exception is:
java.net.SocketException: Permission denied: connect
at com.readAlerts.SendEmailUsingGMailSMTP.main(SendEmailUsingGMailSMTP.java:63)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587;
nested exception is:
[Code]...
Tried every permutation and combination but all leading to this same error.
I just started using java because i want to create a simple web service that will take some values from within a url and save those values in variables.
To be more specific:
For my project I use the Spring Tool Suite.
I want to be able to enter a URL in a browser.. something like "localhost:8080/test?name=Root". When I hit Enter a page will be displayed showing "Hello Root" if the name in the URL is Root or "Hello User" for any other name.
I accomplish that with this code:
Java Code:
String UserName = "Empty";
@RequestMapping("/test")
public @ResponseBody String username(@RequestParam(value="name")String name){
if (name == "Root")
UserName = "Hello" + name;
else
UserName = "Hello User";
return UserName;
} mh_sh_highlight_all('java');
My problem is that it if I enter Root as a name in the URL it doesn't recognize it and it shows "Hello User".
I tried Java Code: << if (name.toString() == "Root") mh_sh_highlight_all('java'); but no luck.
How exactly I should reform this code in order to make it work?
I wrote a Chess game that uses socket to connect to another computer, and allow player vs player and player vs computer game sessions.
However, there is a problem which I noticed.
When you get the IP address of the computer in which the program is running, you are not getting the computer's actual IP, you are getting the Router's IP.
Is there a way to get around this.
So the problem is that when I go to another computer, located in a different house or lets say from my school, the program cannot connect back to my home IP, because it uses the router's ip, not the computer's ip I am running the server program.
Is there a way to get the Computer's IP, not the router's ip when summoning or invoking the get IP address method from the socket class?
When I say that the socket class is acquiring the router's ip, well that's done without my interfering...I don't know why it does that, it is somehow recognizing the router and not the computer.
The thing is that the server program is written that any client program is able to connect to the home server.
But when I run the program from a different location other than the current home, the sockets don't connect because it is somehow recognizing the router's ip not the computer's ip.
In my java program I'm changing my IP(using proxy) and sending the request to some sites. Later some point of time, I want to know my current IP address through java program itself. How to get hold of my current IP address? Also which IP address will it show? The proxy one or the original IP ?
View Replies View Related