Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Ramon Haayema

Greenhorn
+ Follow
since May 17, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ramon Haayema

Hi all,

I need for a program to send packets the real ip adres and not the local adres.
now i get the ip number from the local machine but this is not the internet adres.
exapmle my computer has the following adress from the router 192.168.1.102 but my internet adress is 81.58.155.112
what i need is last adres to send data to the client/server.
or is there a other trick to send?

try {
java.net.InetAddress i = java.net.InetAddress.getLocalHost();
System.out.println(i); // name and IP address
System.out.println(i.getHostName()); // name
System.out.println(i.getHostAddress()); // IP address only

}
catch(Exception e){e.printStackTrace();
}
this give me the local adres but not the internet adress.

this all is for :

public DaemonIn()
{

this.payload = new TcpSendClass();
initServerSocket();
try
{
while (true)
{
// listen for and accept a client connection to serverSocket
Socket sock = this.serverSocket.accept();
InputStream iStream = sock.getInputStream();
ObjectInputStream oiStream = new ObjectInputStream(iStream);
this.payload = (TcpSendClass)oiStream.readObject();
//this.payload =(oiStream.getClass()) oiStream.readObject();
Thread.sleep(1000);
this.payload.hashCode();
System.out.println("recived tcp class");
DaemonLog DL = new DaemonLog();
DL.WriteToLog(this.payload.getClass().getName(),"In");
}

}
catch (SecurityException se)
{
System.err.println("Unable to get client address due to security.");
System.err.println(se.toString());
System.exit(1);
}
catch (IOException ioe)
{
System.err.println("Unable to read data from an open socket.");
System.err.println(ioe.toString());
System.exit(1);
}
catch (InterruptedException ie) { } // Thread sleep interrupted

catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
try
{
this.serverSocket.close();
}
catch (IOException ioe)
{
System.err.println("Unable to close an open socket.");
System.err.println(ioe.toString());
System.exit(1);
}
}
System.out.println("Received payload:");
System.out.println(this.payload.toString());
}

and a reciver but the reciver needs to send back for that i need the adress of the client computer.
please help...
Hi all,

I like to write/read data to my internal tape drive. can't find any thing on the www about where to start.
is there a class/jar/zip anything that has the code to do this? or need i to completely write new code to do this.
any pointers or tips are welcome.

9 years ago
Well, the first jsp coms form a sevlet so there the bean is loaded with data but when i want to go to the second jsp the bean is empty (null).
i like to know how i can reuse the data in the bean in my total web pages.

thanks for the help.
9 years ago
JSP
In the second ( MyshoppingCart ) the bean is empty
9 years ago
JSP
Apache tomcat 6.0 running with Eclipse.
thats where its running on.
9 years ago
JSP
have them both on session now.
problem still exsist....
even when both are on application.
got more ideas?
thanks so far
9 years ago
JSP
what scope do i need than.
becourse i tryed application also but the bean is still empty.
thanks for your help so far.
9 years ago
JSP
Hello,

Can please someone help me with the following problem.
after a login and data is taken out of the data base throu a sevlet the data is set into a bean and works fine in the first jsp file:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="nl.business.dbbean.*" %>
<%@ page session="true" %>
<jsp:useBean id="login" type="nl.business.dbbean.LoginBean" class="nl.business.dbbean.LoginBean" scope="session"></jsp:useBean>
<jsp:setProperty property="*" name="login" />

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Welcome customer : <jsp:getProperty name="login" property="customer" />
<p></p>

<a href="MyShoppingCart.jsp">Go to my shopping cart</a>
</body>
</html>
no problems so far.
but when i want to read the same bean in the myshoppingcart jsp the4 bean is empty

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="nl.business.dbbean.*" %>
<%@ page session="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="login" class="nl.business.dbbean.LoginBean" scope="application"></jsp:useBean>
<jsp:setProperty property="*" name="login" />

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My current ShoppingCart</title>
</head>
<body>
<jsp:getProperty name="login" property="customer"/>

</body>
</html>

is there someting that i am missing?

it all works under apache tomcat and eclipse.

Thanks in advanced.
9 years ago
JSP
Within the jsp file i have a arraylist.
that array list need to get the servlet.
like
<FORM method="post" action="servlet/Servlets.loginservlet">
<H5>User id :<BR>
<INPUT size="10" name="user">
<BR>
Password :<BR>
<INPUT type="password" name="password" size="10"><BR>
<INPUT type="submit" name="Login" value="login">

like this accept,i need to post the arraylist.

i hope this explaind it.
9 years ago
Hi everyone,

i ame trying to post a arraylist to a servlet...
i really havo no idea hoe to this in the form i made.
with the standard input field this is no problem.
i understand how to get to the servlet but not how to post a arraylist.
many thanks in advance.
Ramon
9 years ago
Got it... did a trim on the setter in the bean class.
thankyou for helping.
9 years ago
System.out.println(LB.getRole());
System.out.println(LB.getUser());
System.out.println(LB.getProfile());
if (LB.getRole().equals("admin")) { System.out.println("True");}
else { System.out.println("False " + LB.getRole());}
}
still the same :
admin
Haayema, Ramon
exvgl
False admin
9 years ago
hi everyone the following problem occource

System.out.println(LB.getRole());
System.out.println(LB.getUser());
System.out.println(LB.getProfile());
if ( LB.getRole() == "admin" ) { System.out.println("True");}
else { System.out.println("False " + LB.getRole());}
then the ouput is:

admin
Haayema, Ramon
exvgl
False admin

but the LB(Bean) getRole is admin,
what is that i ame missing.
9 years ago
the connector

public ArrayList getAllAdresses (UserBean u){
if (con == null ){ setupConnection(u); }
ArrayList adressList = new ArrayList();
try {
AdressBean ab = new AdressBean();
stmt = con.createStatement();
rs =stmt.executeQuery("Select * from BO_ISERIES.pfadress");
while (rs.next()){
ab.setFirstName(rs.getString(1));
ab.setLastName(rs.getString(2));
ab.setTitel(rs.getString(3));
ab.setAdress(rs.getString(4));
ab.setZipCode(rs.getString(5));
ab.setCity(rs.getString(6));
ab.setTelephone(rs.getString(7));
ab.setMobileNr(rs.getString(8));
ab.setEMail(rs.getString(9));
adressList.add(ab);

System.out.println("Real one : "+ ab.getFirstName());
}
Iterator it = adressList.iterator();
while (it.hasNext()){
AdressBean wb = (AdressBean)it.next();
System.out.println(wb.getFirstName());
}

then the output is

[17-5-08 19:22:36:438 CEST] 508e3d44 WebGroup I SRVE0180I: [BO-Iseries] [/BO-ISeries] [Servlet.LOG]: Servlets.GetAllAdresses: init
[17-5-08 19:22:36:812 CEST] 508e3d44 SystemOut O Real one : Ramon
[17-5-08 19:22:36:812 CEST] 508e3d44 SystemOut O Real one : Karla
[17-5-08 19:22:36:812 CEST] 508e3d44 SystemOut O Real one : dikkie
[17-5-08 19:22:36:812 CEST] 508e3d44 SystemOut O dikkie
[17-5-08 19:22:36:812 CEST] 508e3d44 SystemOut O dikkie
[17-5-08 19:22:36:812 CEST] 508e3d44 SystemOut O dikkie
[17-5-08 19:22:36:812 CEST] 508e3d44 SystemOut O System numember : 0Beans.AdressBean@3f1bfd4e
[17-5-08 19:22:36:812 CEST] 508e3d44 SystemOut O System numember : 1Beans.AdressBean@3f1bfd4e
[17-5-08 19:22:36:812 CEST] 508e3d44 SystemOut O System numember : 2Beans.AdressBean@3f1bfd4e

so the adresslist hold the same bean.....
what is that wat am i missing?

please help....
10 years ago