Re: Problems emailing from struts

2005-10-27 Thread C.F. Scheidecker Antunes

Hello,

Thanks for the info. I am still having problems sending email from a 
struts action.


I've created a separate class emailClient to send the message. The class 
is on the end

of the email.

I have mailapi.jar under /WEB-INF/lib/ version 1.3.3.01 
 but nothing works.

Here's the exception I am getting:

*exception*

javax.servlet.ServletException: Servlet execution threw an exception

org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)

*root cause*

java.lang.NoClassDefFoundError: javax/activation/DataSource
com.nando.utils.emailClient.doSend(emailClient.java:43)
com.nando.struts.action.TestAction.send2Mail(TestAction.java:51)
com.nando.struts.action.TestAction.execute
(TestAction.java:77)

org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)

org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process
(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java
:802)

org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)



*import* java.util.*;

*import* javax.mail.*;
*import* javax.mail.internet.*;
*import* javax.mail.MessagingException;

*public* *class* emailClient {

*private* *Properties* props;

*protected* Session session;
*protected* Message msg;

/// default constructor/
*public* emailClient() {


}

*public* void doSend(*String* From, *String* To, *String* *Subject*, 
*String* Body) {

props = *new* *Properties*();
props.put("smtp.nando.com","mailhost");

/// Create the session object/
session = Session.getDefaultInstance(props,*null*);
session.setDebug(*true*);

*try* {
msg = *new* MimeMessage(session);

/// From/
InternetAddress fromAddress = *new* 
InternetAddress(From);
msg.setFrom(fromAddress);

/// To address/
InternetAddress toAddress = *new* InternetAddress(To);
msg.addRecipient(Message.RecipientType.TO, toAddress);

/// Subject/
msg.setSubject(*Subject*);

/// Body/
msg.setText(Body);

/// send the message/
Transport.send(msg);
}

*catch* (MessagingException ex) {
*while* ((ex = 
(MessagingException)ex.getNextException()) != *null*) {
ex.printStackTrace();
}
}
}

}

On the action I create an emailClient object and call doSend with the 
params.

It crashes as the messages above.

Borislav Sabev wrote:





java.lang.NoClassDefFoundError: javax/mail/Message
com.nando.struts.action.TestAction.send1Mail(TestAction.java:35)
com.nando.struts.action.TestAction.execute(TestAction.java:69)



Seems that you don't have mail.jar in WEB-INF/lib.

borislav

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Problems emailing from struts

2005-10-27 Thread C.F. Scheidecker Antunes

Hello all,

I've been trying to email from my struts application without success.
I've first tried the standard approach wich is to use javax.mail.* 
javax.mail.internet.* classes.

As on O'reilly's Servlet Cookbook.

Then I've tried commons email, also without success.

So at this point I wonder if I need to add something to my classpath 
within my Tomcat5 which is part of my Fedora core box.


I wonder if I could get some advice on that?

I am having exceptions thrown at SecurityFilter but I haven't done 
anything to my app as far as security goes as it is very simple

at this point, just a simple work for school.

Any ideas?

Here's a test action from my last attempt:

import org.apache.commons.mail.*;


public class TestAction extends Action {
  
  
   private void send1Mail(String From, String To, String Subject, 
String Body) {

   try {
   SimpleEmail email = new SimpleEmail();
   email.setHostName("smtp.mail.br ");
   email.addTo(To);
   email.setFrom(From);
   email.setSubject(Subject);
   email.setMsg(Body);
   email.send();
   }
   catch (EmailException e) {
   getServlet().log("Error Mail : "+e.toString());
   }
  
   }


   public ActionForward execute(
   ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response) throws Exception {

   response.setContentType("text/html");
   PrintWriter out = response.getWriter();
 
  
   String Subject = "Email test ";

   // message to owner.
   String to = "[EMAIL PROTECTED] ";
   String body = "Hello nando,\n\n";
   send1Mail("[EMAIL PROTECTED] 
",to,Subject,body);

   return null;
   }

javax.servlet.ServletException: Servlet execution threw an exception

org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)

*root cause*

java.lang.NoClassDefFoundError: javax/mail/Message
com.nando.struts.action.TestAction.send1Mail(TestAction.java:35)
com.nando.struts.action.TestAction.execute(TestAction.java:69)





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



How to escape a string on a description field

2005-10-24 Thread C.F. Scheidecker Antunes

Hello all,

I am having problems with my struts app.

I am trying to enter a long string on a description field of a MySQL 
database but it crashes if the string has caracters that need to be escaped.


What about the reversed operation when you are to display that on the JSP?

How can I fix that? Would it help if I had a prepared statement?

Shall I use a MySQL function for that?

Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



need to email from action

2005-10-23 Thread C.F. Scheidecker Antunes

Hello all,

I need to email a simple text message from within an action.

I've tried creating a class using javax.mail.* and javax.mail.internet.* 
classes but without success.


I wonder if there is any simple recipe for that.

Thanks,

C.F.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Forcing JSP reloading, avoiding IE caching of it

2005-10-21 Thread C.F. Scheidecker Antunes

Hello all,

I have a struts app that works great on Firefox, however when I use IE I 
have problems with it.
I guess that IE caches the JSP page. So when the action sends the data 
to the JSP I always have the same

thing.

So I read about it and found that if you add on the struts-config.xml 
 it would

solve the issue. Well it does not solve it in its entirely.

I would like to ask if I could have something on the JSP or the HTML 
part of it to force reloading by IE.

Any suggestions?

Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Hide the JSP: Actions, rowBean and JSPs question

2005-10-10 Thread C.F. Scheidecker Antunes

Hi Rajasekhar,

What would be no_access? Just a name value?

In this case all JSPs would be not accessed correct?

Now, if I want to only do this in a folder then I would:

/folder/*

Is it correct?

Thanks,

C.F.



[EMAIL PROTECTED] wrote:


Hi,

   Put the following code in your web.xml. This will not allow any of 
your user to access your JSPs.




  ...
 
   
 no_access
 *.jsp
   
   
 
 ...



Regards,
Rajasekhar Cherukuri






"C.F. Scheidecker Antunes" <[EMAIL PROTECTED]> 
10/10/2005 09:58 AM

Please respond to
"Struts Users Mailing List" 


To
Struts Users Mailing List 
cc

Subject
Hide the JSP: Actions, rowBean and JSPs question






Hello All,

I have an action that reads from the database and return a rowSet bean 
to the request scope.

Then I iterate the bean on my JSP and show the data.

Everything works.

I however have a problem. I can access the JSP straight if I type the URL.

That is, I want the JSP only to be shown if it is called from the 
action. I have a forward called "success" and

mapped to my struts-config.xml. On success I forward to the jsp

I would like to hide the JSP from the user, is it possible?

How?

Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


ForwardSourceID:NT5AE2 



Notice: The information contained in this e-mail message and/or attachments to 
it may contain confidential or privileged information.   If you are not the 
intended recipient, any dissemination, use, review, distribution, printing or 
copying of the information contained in this e-mail message and/or attachments 
to it are strictly prohibited.   If you have received this communication in 
error, please notify us by reply e-mail or telephone and immediately and 
permanently delete the message and any attachments.  Thank you
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Hide the JSP: Actions, rowBean and JSPs question

2005-10-09 Thread C.F. Scheidecker Antunes

Hello All,

I have an action that reads from the database and return a rowSet bean 
to the request scope.

Then I iterate the bean on my JSP and show the data.

Everything works.

I however have a problem. I can access the JSP straight if I type the URL.

That is, I want the JSP only to be shown if it is called from the 
action. I have a forward called "success" and

mapped to my struts-config.xml. On success I forward to the jsp

I would like to hide the JSP from the user, is it possible?

How?

Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Submit buttons getting their value

2005-10-09 Thread C.F. Scheidecker Antunes

But where is PropertyName? The only thing passed to the action is request.
Thanks

Martin Gainty wrote:


Antunes
I thought it was
PropertyName.getValue() ??
M-
- Original Message - From: "C.F. Scheidecker Antunes" 
<[EMAIL PROTECTED]>

To: "Struts Users Mailing List" 
Sent: Sunday, October 09, 2005 6:17 PM
Subject: Submit buttons getting their value



Hello all,

I have two submit buttons, one with a value of Continue and the other 
Back.


How do I check their values?

I've tried request.getAttribute("submit").toString() but I do not get 
anything.


My buttons are like this:

back
continue

They are within the same form structure.

My action has already a Session Bean scope to save the form contents. 
But the submit is not

in that DynaBean.

I will decide on what to do within the action based on what button is 
pressed.


Thanks,
C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Submit buttons getting their value

2005-10-09 Thread C.F. Scheidecker Antunes

Hello all,

I have two submit buttons, one with a value of Continue and the other Back.

How do I check their values?

I've tried request.getAttribute("submit").toString() but I do not get 
anything.


My buttons are like this:

back
continue

They are within the same form structure.

My action has already a Session Bean scope to save the form contents. 
But the submit is not

in that DynaBean.

I will decide on what to do within the action based on what button is 
pressed.


Thanks,
C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Fast war deployment

2005-10-07 Thread C.F. Scheidecker Antunes

Hello all:

Everytime I deploy my .war file on my server, restart Tomcat and access 
the JSPs and
actions it will compile (make JSPs servlets) and load them. It takes a 
time the first time.


This gets annoying as the application gets bigger.

Is there any way to deploy the war and have a build file?
Can I accomplish that with ant?
If so, how?

Thanks!

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Struts and mod_jk weird behaviour

2005-09-21 Thread C.F. Scheidecker Antunes

Hello all,

I have a struts apps that work great if I connect to 
http://localhost:8080/App


My Tomcat also has two other apps 
http://localhost:8080/servlets-examples and 
http://localhost:8080/jsp-examples.


However both the servlets-examples and jsp-examples work perfectly with 
mod_jk but my struts application App does not!


How can two applications work fine under mod_jk while the other does 
not? As you will see the configuration is not different.


If I access http://localhost:8080/App I see all my jsps, directories 
etc. But if I click on a JSP I get:

HTTP Status 404: /App/login.jsp
Description: The requested resource /App/login.jsp is not available.

Now, for the other 2 apps if I click on a jsp it is executed.

I've checked all including file permissions and I do not seem to see the 
problem. I am getting crazy here!

So I tought you might be able to give me a hand.
I am including my mod_jk and workers.properties here

I then configured my /etc/http/conf.d/mod_jk as follows:
_

LoadModule  jk_module modules/mod_jk.so

JkWorkersFile   /etc/httpd/conf/workers.properties
JkLogFile   logs/mod_jk.log
JkLogLevel  error
JkMount /*.jsp ajp13
JkMount /*.do ajp13
JkMount /servlet/* ajp13

Alias /jsp-examples "/home/antunes/tomcat/webapps/jsp-examples"

   Options Indexes FollowSymLinks


Alias /servlets-examples "/home/antunes/tomcat/webapps/servlets-examples"

   Options Indexes FollowSymLinks


Alias /App "/home/antunes/tomcat/webapps/App"

   Options Indexes FollowSymLinks


JkMount /jsp-examples/servlet/* ajp13
JkMount /jsp-examples/*.jsp ajp13

JkMount /servlets-examples/servlet/* ajp13
JkMount /servlets-examples/*.jsp ajp13

JkMount /App/servlet/* ajp13
JkMount /App/*.jsp ajp13
JkMount /App/*.do ajp13


   AllowOverride None
   deny from all



   AllowOverride None
   deny from all



   AllowOverride None
   deny from all


my /etc/http/conf/workers.properties as follows:
_

workers.tomcat_home=/home/antunes/tomcat
workers.java_home=/usr/lib/jvm/java
# You should configure your environment slash... ps=\ on NT and / on UNIX
# and maybe something different elsewhere.
#
ps=/
worker.ajp12.port=8007
worker.ajp12.host=localhost
worker.ajp12.type=ajp12
worker.ajp12.lbfactor=1
#
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1

worker.jboss.port=8809
worker.jboss.host=localhost
worker.jboss.type=ajp13
worker.jboss.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=ajp12, ajp13, jboss
worker.inprocess.type=jni
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)tomcat.jar
worker.inprocess.cmd_line=start
worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)lib$(ps)i386$(ps)server$(ps)libjvm.so
worker.inprocess.stdout=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stdout
worker.inprocess.stderr=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stderr


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



check radiobutton option based on value posted to the session 2

2005-08-29 Thread C.F. Scheidecker Antunes

Hello all,

I have a radiobutton group called categID. Once the form is submited it 
goes to the following form bean:


**
**
   **


That is the catForm has an attribute called categID with the value posted.
This is a DynaActionForm that resides on the session scope.

Once the form is submited I need to show the radio group again on the 
next page with the one selected already checked.
How can I check this DynaActionForm from the session on the JSP and see 
if the corresponding radiobutton is to be checked or not?


My JSP is as follows:

  
   type="radio" value="">
   name="row" property="Title"/>

   


The problem is that I am already iterating a bean to fill up the value 
of the radiobuttons. If I am to use the  tag
then I would need a way to have the bean row catID property value inside 
the tag. How can I accomplish it?


Thanks,

C.F.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RowSetDynaClass weird problem

2005-08-29 Thread C.F. Scheidecker Antunes

Never mind. It was fixed by using low caps property names for the bean.
Thanks.

C.F. Scheidecker Antunes wrote:


Hello all,

I've done it before, in one project it works perfectly in the other it 
doesn't so I was hoping
I could get some help from you. This new project tries to create a 
Radiobutton table on the fly

using RowSetDynaClass

I have an action that calls a DAO which returns a RowSetDynaClass like 
this:


*public* ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
   
*DataSource* dataSource = *null*;

*Connection* conn = *null*;
RowSetDynaClass rowSet = *null*;
   
*try* {

dataSource = getDataSource(request,"ds1");
conn = dataSource.getConnection();
   
CategoryDAO dao = *new* CategoryDAO();

*String* SQL = "SELECT catID,Title FROM tbl_catSimple";
rowSet = dao.getUsersRowSet(dataSource,SQL);
*if* (!rowSet.getRows().isEmpty()) {
request.setAttribute("rowCatSet",rowSet);
}
} *catch* (*SQLException* sqle) {
getServlet().log("Connection process ",sqle);
} *catch* (*Exception* e) {
getServlet().log("Exception ",e);
} *finally* {
*try* {
*if* (conn != *null*) {
conn.close();
}
} *catch* (*SQLException* e) {
getServlet().log("Connection close ",e);
}
}

*if* (request.getSession().getAttribute("userid") != *null*) {
DynaActionForm catForm = (DynaActionForm) 
request.getSession().getAttribute("catForm");

*if* (catForm.getString("cat_ID") != *null*) {

request.setAttribute("cat_ID",catForm.getString("cat_ID"));

}
*return* mapping.findForward("form");
}
   
*return* mapping.findForward("error");

}


The CategoryDao class has the following method which returns a 
RowSetDynaClass


*  public* RowSetDynaClass getUsersRowSet(*DataSource* dataSource, 
*String* SQL) *throws* *Exception* {
   
*Connection* conn= *null*;

*ResultSet* rs   = *null*;
*Statement* stm  = *null*;
RowSetDynaClass rowSet = *null*;
   
*try* {

conn = dataSource.getConnection();
stm = conn.createStatement();
rs = stm.executeQuery(SQL);
rowSet = *new* RowSetDynaClass(rs);
} *catch* (*SQLException* sqle) {
///getServlet().log("Connection process ",sqle);/
} *finally* {
*if* (conn != *null*) {
conn.close();
}
}
*return* rowSet;
}



The action works perfectly, the rowSet is saved on the request scope 
as rowCatSet and the findForward("form") is called which is my 
catform.jsp.


The JSP content is as follows:

*<%* *if* (request.getAttribute("rowCatSet") != *null*) { *%>*


**

   
  **
  **
  **
   
  **  
type="radio" value="**">
*name="row" property="Title"*/>*


  **   
   value="4">

   motorcycles
 



*<%* } *%>

Please notice, that I first check to see if rowCatSet is null, since 
it is not I do the iteration.


However I get the following error: "No getter method for property 
catID of bean row"!

If I erase it I have the same error for the second property Title.
*

What is going on with this RowSetDynaClass? What have I done wrong? 
Why is that my row does not have a property named catID if it is 
specified on the SQL statement and does return correctly?


Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RowSetDynaClass weird problem

2005-08-29 Thread C.F. Scheidecker Antunes

Hello all,

I've done it before, in one project it works perfectly in the other it 
doesn't so I was hoping
I could get some help from you. This new project tries to create a 
Radiobutton table on the fly

using RowSetDynaClass

I have an action that calls a DAO which returns a RowSetDynaClass like this:

*public* ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {

*DataSource* dataSource = *null*;
*Connection* conn = *null*;
RowSetDynaClass rowSet = *null*;

*try* {
dataSource = getDataSource(request,"ds1");
conn = dataSource.getConnection();

CategoryDAO dao = *new* CategoryDAO();
*String* SQL = "SELECT catID,Title FROM tbl_catSimple";
rowSet = dao.getUsersRowSet(dataSource,SQL);
*if* (!rowSet.getRows().isEmpty()) {
request.setAttribute("rowCatSet",rowSet);
}
} *catch* (*SQLException* sqle) {
getServlet().log("Connection process ",sqle);
} *catch* (*Exception* e) {
getServlet().log("Exception ",e);
} *finally* {
*try* {
*if* (conn != *null*) {
conn.close();
}
} *catch* (*SQLException* e) {
getServlet().log("Connection close ",e);
}
}

*if* (request.getSession().getAttribute("userid") != *null*) {
DynaActionForm catForm = (DynaActionForm) 
request.getSession().getAttribute("catForm");
*if* (catForm.getString("cat_ID") != *null*) {

request.setAttribute("cat_ID",catForm.getString("cat_ID"));
}
*return* mapping.findForward("form");
}

*return* mapping.findForward("error");
}


The CategoryDao class has the following method which returns a 
RowSetDynaClass


*  public* RowSetDynaClass getUsersRowSet(*DataSource* dataSource, *String* 
SQL) *throws* *Exception* {

*Connection* conn= *null*;
*ResultSet* rs   = *null*;
*Statement* stm  = *null*;
RowSetDynaClass rowSet = *null*;

*try* {
conn = dataSource.getConnection();
stm = conn.createStatement();
rs = stm.executeQuery(SQL);
rowSet = *new* RowSetDynaClass(rs);
} *catch* (*SQLException* sqle) {
///getServlet().log("Connection process ",sqle);/
} *finally* {
*if* (conn != *null*) {
conn.close();
}
}
*return* rowSet;
}



The action works perfectly, the rowSet is saved on the request scope as 
rowCatSet and the findForward("form") is called which is my catform.jsp.


The JSP content is as follows:

*<%* *if* (request.getAttribute("rowCatSet") != *null*) { *%>*


**

   
  **
  **
  **
   
  **  
	

*">
**

  **  
 

   
   motorcycles
 



*<%* } *%>

Please notice, that I first check to see if rowCatSet is null, since it is not 
I do the iteration.

However I get the following error: "No getter method for property catID of bean 
row"!
If I erase it I have the same error for the second property Title.
*

What is going on with this RowSetDynaClass? What have I done wrong? Why 
is that my row does not have a property named catID if it is specified 
on the SQL statement and does return correctly?


Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Questions about RowSetDynaClass

2005-08-24 Thread C.F. Scheidecker Antunes

Hello all,

I would like to ask a few questions about RowSetDynaClass.

I can successfully set up one in a DAO class and include it in the 
request scope of an action class to forward to a JSP.


The problem is with the JSP.

Problem number one:
- If the bean is null or empty I have an error, that is if the database 
does not return anything. So is there a way to check if it is null or empty
before iterating so that I have no errors? Further, if the bean is not 
in the request scope I also have an error saying that the bean was not 
defined. How can I avoid this error? That is check to see if there is a 
rowSet bean before using it in the JSP?


Problem number two:
- The following code iterates the entire cols set and write all the 
columns from that row:


 
 
 



OK, the second iterate writes as many  as the number of columns 
for that row. However I wanted to do that for each and every column as I 
need to add links to a few. Hence, shall I strip the inner most iterate 
and have  for each column? How can I get an
specific column name? Shall I pass that to .getName() function so that 
.getName("column1") ?

How does it work?

Thanks,

C.F.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



How to Debug easier

2005-08-21 Thread C.F. Scheidecker Antunes

Hello all,

If I have a System.out.Println() statement on my Struts code where would 
that be written to?


I would like to write stuff to either the console or the Tomcat log text 
file. How can I achieve that?


System.out.println() does not seem to be doing anything.

I want to know what it is going on at run time to make it easier to 
debug stuff.


Any suggestions?

Thanks,

C.F.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: List selection manager 'widget'

2005-08-21 Thread C.F. Scheidecker Antunes

Hi Laurie,

I am trying to do the same and I've done some research. One of the 
things I've found is the one bellow.


I would appreciate, if you find something diferent, to email it back to 
the list as well so that it would same time for me

and other developers as well.

Thanks,

C.F.

Maybe something like this would work for you:

http://javascript.js-x.com/examples/example.php?title=Multiple%20dynamic%20combo%20boxes%20Builder





/*
*** Multiple dynamic combo boxes
*** by Mirko Elviro, 9 Mar 2005
***
***Please do not remove this comment
*/

// This script supports an unlimited number of linked combo boxed
// Their id must be "combo_0", "combo_1", "combo_2" etc.
// Here you have to put the data that will fill the combo boxes
// ie. data_2_1 will be the first option in the second combo box
// when the first combo box has the second option selected


// first combo box
data_1 = new Option("1", "$");
data_2 = new Option("2", "$$");

// second combo box
data_1_1 = new Option("11", "-");
data_1_2 = new Option("12", "-");
data_2_1 = new Option("21", "--");
data_2_2 = new Option("22", "--");
data_2_3 = new Option("23", "--");
data_2_4 = new Option("24", "--");
data_2_5 = new Option("25", "--");

// third combo box
data_1_1_1 = new Option("111", "*");
data_1_1_2 = new Option("112", "*");
data_1_1_3 = new Option("113", "*");
data_1_2_1 = new Option("121", "*");
data_1_2_2 = new Option("122", "*");
data_1_2_3 = new Option("123", "*");
data_1_2_4 = new Option("124", "*");
data_2_1_1 = new Option("211", "**");
data_2_1_2 = new Option("212", "**");
data_2_2_1 = new Option("221", "**");
data_2_2_2 = new Option("222", "**");
data_2_3_1 = new Option("231", "***");
data_2_3_2 = new Option("232", "***");

// fourth combo box
data_2_2_1_1 = new Option("2211","%")
data_2_2_1_2 = new Option("2212","%%")

// other parameters
displaywhenempty="-empty-"
valuewhenempty=-1

displaywhennotempty="-select-"
valuewhennotempty=0


function change(currentbox)
{
var numb = currentbox.id.split("_");
var currentbox = numb[1];
var i=parseInt(currentbox)+1;
// I empty all combo boxes following the current one
var _t=eval("typeof(document.getElementById('combo_"+i+"'))!='undefined'");
while (_t && document.getElementById("combo_"+i)!=null)
{
var son = document.getElementById("combo_"+i);
// I empty all options except the first (it isn't allowed)
for (m=son.options.length-1;m>0;m--)
son.options[m]=null;
// I reset the first option
son.options[0]=new Option(displaywhenempty,valuewhenempty);
i=i+1;
}

// now I create the string with the "base" name ("stringa"), ie. "data_1_0"
// to which I'll add _0,_1,_2,_3 etc to obtain the name of the combo box to fill
var stringa='data';
i=0;
_t=eval("typeof(document.getElementById('combo_"+i+"'))!='undefined'");
while (_t && document.getElementById("combo_"+i)!=null)
{
eval("stringa=stringa+'_'+document.getElementById(\"combo_"+i+"\").selectedIndex");
if (i==currentbox)
break;
i=i+1;
}

// filling the "son" combo (if exists)
var following=parseInt(currentbox)+1;
_t=eval("typeof(document.getElementById('combo_"+following+"'))!='undefined'");
if (_t && document.getElementById("combo_"+following)!=null)
{
son=document.getElementById("combo_"+following);
stringa=stringa+"_";
i=0;
while ((eval("typeof("+stringa+i+")!='undefined'")) || (i==0))
{
// if there are no options, I empty the first option of the "son" combo
// otherwise I put "-select-" in it
if ((i==0) && eval("typeof("+stringa+"0)=='undefined'"))
if (eval("typeof("+stringa+"1)=='undefined'"))
eval("son.options[0]=new Option(displaywhenempty,valuewhenempty)");
else
eval("son.options[0]=new Option(displaywhennotempty,valuewhennotempty)");
else
eval("son.options["+i+"]=new Option("+stringa+i+".text,"+stringa+i+".value)")
i++;
}
//son.focus();
i=1;
combostatus='';
cstatus=stringa.split("_");
while (cstatus[i]!=null)
{
combostatus=combostatus+cstatus[i];
i=i+1;
}
return combostatus;
}
}





-select-
1
2



 



 



 


>javascript.js-x.com 






Laurie Harper wrote:

Does anybody have, or know of, a good HTML form 'widget' for managing 
value lists, something like


   AvailableSelected
  +-+  ++
  | item A  |>>|   ||
  | item B  |>>||
  | item C  |<<||
  | ... |   |<<||

(you know the kind of thing ;-)

I'd like something that is used as similarly to the simple controls as possible, and preferably something with some nice 
client-side behaviour built in.


It's not rocket science, shouldn't be hard to build, but I thought I 
might as well try to avoid reinventing the wheel ;-) [and yes, I know 
this kind of thing is where JSF comes into its own, but JSF isn't an 
option on this project...]

Re: Login Problem

2005-08-19 Thread C.F. Scheidecker Antunes

Take a look at O'Reilly's Struts Cookbook about this issue.

d d wrote:


 I am working on a struts web application with oracle as back end.I use tomcat. 
I am using filter so that if user has not logged in he cannot access any of the 
pages.I have a problem for logging..
I login into my application..Use the application..Now if suddenly i close 
Tomcat Server.. and restart it ..and refresh my old page..it continues to work.
This perticularly happens if there is a action in url..
e.g address bar has. "http/localhost:8080/web/app/ss.do" and the server is 
restarted, filter does not work..and page continues to flow.
and if address bar contains "http/../ss.jsp" filter works and user is 
forced to login.
I havent judged the exact problem yet .Can anyone help me?
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Resizing output image from a Struts Action

2005-08-18 Thread C.F. Scheidecker Antunes

Hello all,

I have an action to retrieve an image from a database BLOB field and 
display it.

It works great.

However I wanted to resize the image proportionaly. Hence I think on 
writing a second action, that would
call the first in order to retrieve the image. Then, would work on this 
image to resize it and send it over to the browser.

Or maybe change the original action to do that to save the overhead.

I would like to know how to accomplish image resizing in Java. The image 
can be a JPG, a GIF or a BMP. Hence I need to handle
all these situations depending on the Content/Type that is stored in the 
database along with the BLOB.


When you retrieve a BLOB you write it to a ByteArrayOutputStream. Then 
you just set the response.SetContentType , setContentLength and send the 
ByteArrayOutputStream by calling the method .toByteArray() and .flush.


I have two options, I can change the original Action to accept a request 
attribute to determine the width or height. Then I can work the image 
and spit it out. The way I think about it is that I would need to, 
somehow, create an Image object by taking the ByteArray from the 
ByteArrayOutputStream. This image object could be a JPG, GIF or BMP. I 
would determine which one to use based on the Content/Type of the 
database. They this object could be resized and return a byteArray that 
I could send to the browser.


I guess I have most of it done but I would like advise on how to:

1) Construct a JPG, GIF or BMP object with the ByteArray
2) Resize this object and produce a resided ByteArray so that I can send 
it to the browser.


Any ideas on how to perform that?

Any documentation regarding this that I could browse?

Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Question on log on with SecurityFilter and JDBCRealm

2005-08-18 Thread C.F. Scheidecker Antunes

Steven,

Thanks!
Yeah, great idea. In fact I was reading about that on O'Reilly's Struts 
Cookbook.


I have one question to you though:

How is the filter executed? After the login? Or after every http request 
to the server?
What does fire the filter up? Is it like an event for a GUI app? I would 
like to understand this

concept better.

regards,

C.F.

Mitchell, Steven C wrote:


Have you considered using a Filter to put the extra stuff in your
Session?  We use an initialization Filter that looks up a User record
based on the authenticated user id.  We then place that User object both
in the Session and a thread local variable so that it is available to
all the layers of our framework.  Our DAO classes use the thread local
variable to set things like Last Updated By.  If you use the thread
local variable make sure the last thing the Filter does is to set it to
null so that the thread is not returned to the container's thread pool
with the User object.

public void doFilter( final ServletRequest servletRequest, 
   final ServletResponse servletResponse, 
   final FilterChain filterChain )

   throws IOException, ServletException
   {
   if ( servletRequest instanceof HttpServletRequest )
   {
   final HttpServletRequest httpServletRequest = 
   (HttpServletRequest) servletRequest;

   final String remoteUser =
httpServletRequest.getRemoteUser();
   if ( DataHelper.empty( remoteUser ) || 
   "null".equalsIgnoreCase( remoteUser ) )

   {
   if ( log.isDebugEnabled() )
   {
   log.debug( "No User info Available" );
   } //end if
   
   ThreadContext.setUser( null );

   } //end if
   else
   {
   final HttpSession session =
httpServletRequest.getSession( true );
   User user = (User) session.getAttribute(
SESSION_TOKEN_SYSUSER );
   if ( user == null )
   {
   try
   {
   user = UserController.findUserByLoginId(
remoteUser );
   if ( log.isDebugEnabled() )
   {
   log.debug( "Initializing user " +
user.getUserId() );
   } //end if
   } //end try
   catch ( final Exception e )
   {
   throw new ServletException( e );
   } //end catch
   
   session.setAttribute( SESSION_TOKEN_SYSUSER, user );

   } //end if
   
   ThreadContext.setUser( user );

   } //end else
   } //end if

   filterChain.doFilter( servletRequest, servletResponse );
   ThreadContext.setUser( null ); //Clear the thread before
returning it to the server's thread pool
   }

Steve Mitchell
UMB Bank

-Original Message-
From: C.F. Scheidecker Antunes [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 17, 2005 12:50 PM

To: Struts Users Mailing List
Subject: Question on log on with SecurityFilter and JDBCRealm


Hello all,

I've managed to have successful authentication with securityFilter and 
JDBCRealm.


I have a few questions that I was hoping you could clarify for me.

After the login is successful, is there any way to forward that to a 
success page/action
so that I can add extra stuff to the session context? This is my 
 session

in the securityfilter-config.xml file:

**
 **FORM**
 **
**/login.jsp**
**/error.jsp**
**/index.html**
 **
  **


My second question is concernig accessing the username value from the 
session context.

How is that stored in the session? How can I access it?
My login.jsp form uses standard j_security_check for the action on the 
login form, j_username, j_password for the 2 inputs.


I would like, after the login is succesful to forward that to an action 
in order to access the database using the username as a key and return

an userID number that I also want to store in the session. How can I
accomplish this?

Thanks in advance,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Struts and Laszlo

2005-08-18 Thread C.F. Scheidecker Antunes

Luc,

I have designed Laszlo applications having both PHP and Servlets as 
controllers.

It worked great and your idea is right on.
In fact I am starting a Struts/Laszlo app pretty soon.
Have in mind that Laszlo is the View of the MVC model.
I understand that you can also use Laszlo as the controler.
But I had a project done for School with laszlo and Servlets and the way 
I've used Laszlo was to
act as the view model and do browser validation as you can have 
Javascript with Laszlo.
Other than that all the logic and interaction with the business layer 
were done by my servlets.

With Struts the principle is the same.

Keep in mind one thing for Laszlo. Even if you only post data to your 
Struts action you have to return some

sort of xml structure or your Laszlo app will crash.
Something like:

success

or 

Basicaly instead of having a JSP front end you will have a Laszlo front end.
However programming it with Laszlo is more like doing a GUI app with 
events and all other

than a CGI application.

good luck Luc

Lucas Bern wrote:


Hia guys...

I´would it be a nosense to integrate Laszlo with struts???

I think Laszlo is responsible for controlling the application, so, may be we 
can hav struts incharge of generating data in XML format so that Laszlo 
presentation server show it???

I´m thinking of extending struts so that its output be XML for laszlo (or who 
ever), abstracting it form HTML...

am I making a mountain from a stone ...

I mean, a servlet would be enough???

Luc

__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Problems declaring DataSources

2005-08-18 Thread C.F. Scheidecker Antunes

Hi all,

Problem solved. So I will share the solution in case someone has the 
same problem.


Just use the following class:
com.mysql.jdbc.jdbc2.optional.MysqlDataSource  as the DataSource class.
so, the correct code is:


   type="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">

 
 value="jdbc:mysql://localhost:3306/Test" />

 




    
    

  


Thanks.

C.F. Scheidecker Antunes wrote:


Hello All,

I have the following datasource declared. The password, URL and user 
name as well as Database name (on the URL) are corrected and I have 
them tested.

Here it is:


type="org.apache.commons.dbcp.BasicDataSource">
  value="com.mysql.jdbc.Driver" />
  value="jdbc:mysql://localhost:3306/Test" />

  
 
 
 
 
 
 
 
   



However, when I put it in my struts-config.xml I have the erros bellow.

What am I missing here? Am I missing any properties? Shall I use any 
other type other than org.apache.commons.dbcp.BasicDataSource for MySQL?


Thanks,

C.F.

Errors:

SEVERE: Unable to initialize Struts ActionServlet due to an unexpected 
exception or error thrown, so marking the servlet as unavailable.  
Most likely, this is due to an incorrect or missing library dependency.
java.lang.NoClassDefFoundError: 
org/apache/commons/pool/impl/GenericObjectPool

at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
at java.lang.Class.getConstructor0(Class.java:2640)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at 
org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143) 

at 
org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:805) 

at 
org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)

at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at 
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091) 

at 
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:925)
at 
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3857) 

at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:4118)
at 
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759) 

at 
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at 
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at 
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:894) 

at 
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:857) 

at 
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)

at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1102)
at 
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) 

at 
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 

at 
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at 
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at 
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at 
org.apache.catalina.core.StandardService.start(StandardService.java:450)
at 
org.apache.catalina.core.StandardServer.start(StandardServer.java:683)

at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 

at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 


at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Aug 18, 2005 2:33:21 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet action as unavailable
Aug 18, 2005 2:33:21 AM org.apache.catalina.core.StandardContext 
loadOnStartup

SEVERE: Servlet /upload2 threw load() exception
javax.servlet.UnavailableException: 
org/apache/commons/pool/impl/GenericObjectPool
at 
org.apache.struts.action.ActionServlet.init(ActionServlet.java:368)

at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at 
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091) 

at 
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:925)
at 
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3857) 

at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:4118)
at 
org.apache.catalina.cor

Problems declaring DataSources

2005-08-18 Thread C.F. Scheidecker Antunes

Hello All,

I have the following datasource declared. The password, URL and user 
name as well as Database name (on the URL) are corrected and I have them 
tested.

Here it is:



  
  
  
 
 
 
 
 
 
 
   



However, when I put it in my struts-config.xml I have the erros bellow.

What am I missing here? Am I missing any properties? Shall I use any 
other type other than org.apache.commons.dbcp.BasicDataSource for MySQL?


Thanks,

C.F.

Errors:

SEVERE: Unable to initialize Struts ActionServlet due to an unexpected 
exception or error thrown, so marking the servlet as unavailable.  Most likely, 
this is due to an incorrect or missing library dependency.
java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
at java.lang.Class.getConstructor0(Class.java:2640)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at 
org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
at 
org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:805)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at 
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at 
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:925)
at 
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3857)
at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:4118)
at 
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at 
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at 
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:894)
at 
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:857)
at 
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1102)
at 
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at 
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at 
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at 
org.apache.catalina.core.StandardService.start(StandardService.java:450)
at 
org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Aug 18, 2005 2:33:21 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet action as unavailable
Aug 18, 2005 2:33:21 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /upload2 threw load() exception
javax.servlet.UnavailableException: 
org/apache/commons/pool/impl/GenericObjectPool
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:368)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at 
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at 
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:925)
at 
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3857)
at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:4118)
at 
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at 
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at 
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:894)
at 
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:857)
at 
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)
at org.apache.ca

Database Best Practices

2005-08-17 Thread C.F. Scheidecker Antunes

Hello all,

In order to access a Database on my Model layer, which one is best?

1) A DataSource declared on the struts-config.xml. Then get the 
DataSource on your code inside either your actions or business classes.


2) Create a class that will load the database Driver ,establish the 
connection and return a Connection object through a getConnection() 
static function?


It seems to me that the second is better although it takes a little more 
effort.


Any thoughts on that?

Thanks in advance,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Datasources for Struts 1.2.x

2005-08-17 Thread C.F. Scheidecker Antunes

Hi all,

Forget this last posting. I've found the class! :)
There was a problem on my archive.



C.F. Scheidecker Antunes wrote:


Hello all,

On the Struts: How to Access a Database document the way to set up a 
Datasource is shown in the MySQL example.


However the DataSource class type that is used is the 
org.apache.commons.dbcp.BasicDataSource.


I've downloaded commons dbcp version 1.2.1 and there is no 
BasicDataSource class.

Hence I wonder what to do in this case.

I have placed commons-dbcp-1.2.1.jar under my lib directory along with 
mysql-connector-java-3.1.10-bin.jar.
The MySQL connector is seen and works, however the commons-dbcp jar 
does not include the BasicDataSource class.


What am I missing here?

Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Datasources for Struts 1.2.x

2005-08-17 Thread C.F. Scheidecker Antunes

Hello all,

On the Struts: How to Access a Database document the way to set up a 
Datasource is shown in the MySQL example.


However the DataSource class type that is used is the 
org.apache.commons.dbcp.BasicDataSource.


I've downloaded commons dbcp version 1.2.1 and there is no 
BasicDataSource class.

Hence I wonder what to do in this case.

I have placed commons-dbcp-1.2.1.jar under my lib directory along with 
mysql-connector-java-3.1.10-bin.jar.
The MySQL connector is seen and works, however the commons-dbcp jar does 
not include the BasicDataSource class.


What am I missing here?

Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Question on log on with SecurityFilter and JDBCRealm

2005-08-17 Thread C.F. Scheidecker Antunes

Hello all,

I've managed to have successful authentication with securityFilter and 
JDBCRealm.


I have a few questions that I was hoping you could clarify for me.

After the login is successful, is there any way to forward that to a 
success page/action
so that I can add extra stuff to the session context? This is my 
 session

in the securityfilter-config.xml file:

**
 **FORM**
 **
**/login.jsp**
**/error.jsp**
**/index.html**
 **
  **


My second question is concernig accessing the username value from the 
session context.

How is that stored in the session? How can I access it?
My login.jsp form uses standard j_security_check for the action on the 
login form, j_username, j_password for the 2 inputs.


I would like, after the login is succesful to forward that to an action 
in order to access the database using the username as a key and return

an userID number that I also want to store in the session.
How can I accomplish this?

Thanks in advance,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Multiple file upload

2005-08-16 Thread C.F. Scheidecker Antunes
Thanks that's what I thought regarding the form. But what I really want 
is to know how to separate them when they are uploaded.
Files are uploaded like email mime attachments. So there is a begining 
and end of each file. Therefore, how do you separate them?
I image that you would have to create a FormBean to accept n file inputs 
and then get the content to each one separately and assign them to a 
stream class. Checking for each input whether it is null or not.


Laurie Harper wrote:


C.F. Scheidecker Antunes wrote:

Is there any way to perform multiple file uploads using Jakarta 
Commons Upload on a Struts application?

Is there any howto on this issu?



Just use multiple file inputs on the form. There's no way to provide a 
single 'select multiple files to upload' widget, if that's what you're 
asking; HTML only provides the single-file form input. But there's 
nothing to stop you having more than one of them on a page.


L.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



getting a Form from the Session Scope from another Action

2005-08-15 Thread C.F. Scheidecker Antunes

Hello all,

Say that I have the following situation:












Ok, the first action calls a jsp that, when submited, calls ProcessStep1 
action and populates the Step1Form. However on step2 I am doing a file 
upload so I am declaring the form, which is not Step1Form, to be of 
request scope not session scope. Hence everytime the values of that form 
are reset. However, within step2 Action I would like to retrieve 
Step1Form as well so that I can work with values from both form: 
Step1Form which is session scope and Step1Form which is request Scope.


So my big question is: How can I retrieve from session scope Step1Form 
within the step2 Action?

Step2Form can be easily retrieved inside step2 action by:
Step2Form form2 = (Step2Form) form;

How can I retrieve Step1From in this action (step2) as well?
The execute function passes just one ActionForm form which I am using 
for the Step2Form as specified on the struts-config.xml.


So can I, somehow, access Step1Form from the session scope?

Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Multiple file upload

2005-08-15 Thread C.F. Scheidecker Antunes

Hello all,

Is there any way to perform multiple file uploads using Jakarta Commons 
Upload on a Struts application?

Is there any howto on this issu?

Thanks,
C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



All session variables and their values

2005-08-14 Thread C.F. Scheidecker Antunes

Hello all,

How can I list/print on a JSP all the variables and their values of the 
current user session?


Better yet, how can I log it to a file.

Thanks in advance,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Using Security Filter with JDBCRealm questions

2005-08-12 Thread C.F. Scheidecker Antunes

Hello all,

This is my attempt on using SecurityFilter + JDBCRealm for 
Authenticating a Struts Application.
If it works, I will post a simple howto to help other folks with the 
same difficulties on my school webpage.
So I appreciate all the input, opinions and help that anyone can give me 
on the following issues as well as

my configuration so far.

For what I can see on the examples that come bundled with SecurityFilter 
2.0 the Catalina Realm can be declared inside

the securityfilter-config.xml.

Hence If I put my database information and use a JDBCRealm it shoud work 
with the database authentication as well.

So if I add the following on my securityfilter-config.xml:

**

Question: Shall I remove  all the  tags from 
my Tomcat server.xml so that they get overriden by this one on the

securityfilter-config.xml? Or will they get overriden no matter what?

Question: Shall I add the Catalina realm adapter on my 
securityfilter-config.xml as well? Say something like the following:


* 
*

I guess this one should be done before the JDBCRealm Realm, correct?


Then specify within the same /WEB-INF/securityfilter-config.xml the 
 tag as follows:


**
   **FORM**
   **Name**
   **
  **/login.jsp**
  **/error.jsp**
   **
 **

Question: What shall I specify on the  tag or shall I leave 
it blank or remove it?


I can then protect my JSPs within the securityfilter-config.xml as follows:

The first one allows users with a Role of a "participant" as well as an 
administrative user with "admin" role to access /participants.jsp.
The second security constraint allows for administrative users only to 
access admin.jsp. Both require SSL by specifing CONFIDENTIAL

on the  user data constraint tag.

*security-constraint>*
   **
 **Participants**
 **/participants.jsp**
   **
   **
 **participant**
   **
   **
 **admin**
   **
   **
 **CONFIDENTIAL**
   **
 **
 
 **

   **
 **Admin**
 **/admin.jsp**
   **
   **
 **admin**
   **
   **
 **CONFIDENTIAL**
   **
 **


Now, regarding the login.jsp. The example on the SecurityFilter uses 
custom Constants from a class org.securityfilter.example.Constants.
This is a class that defines static final String constants, nothing more 
as far as the code shows.

Those are:
LOGIN_FORM_ID. By looking at the class it is a String of value "loginform".
LOGIN_USERNAME_FIELD. It is actually j_username which is what you are 
supposed to use for Container Authentication.

LOGIN_PASSWORD_FIELD = j_password.
LOGIN_REMEMBERME_FIELD = j_rememberme.

Question:
SecurityFilter than expects that you use a login form with the standard 
Container Authentication field names like j_username, j_password. Is 
this correct?


Final question: As far as verifying the user is authorized to access an 
URL based on its security role and profile besides what says in the 
securityfilter-config.xml
shall I use a Servlet Filter to verify the user and then forward he/she 
to a page if he or she does not have access to that URL or JSP page?


Thanks in advance!

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] Tomcat, JAAS and Kerberos

2005-08-12 Thread C.F. Scheidecker Antunes

Wendy,

Check out this article on JAAS with LDAP. I am sure that it might not be 
as hard to use Kerberos. I've seen an example of the userClassNames and 
roleClassNames somewhere this week. Let me see if I find it and I will 
forward it to you.


The article on JAAS is at:
http://www.theserverside.com/articles/article.tss?l=Pramati-JAAS

Wendy Smoak wrote:

As I mentioned earlier today, we've licensed a (Struts-based, so I'm 
not *entirely* off topic) third-party webapp that comes pre-configured 
to do LDAP authentication.  We, of course, do not have LDAP.  We have 
Kerberos. Easy enough, I thought... surely there's a KerberosRealm I 
can configure and plug in.  Apparently not.


I can successfully authenticate with Kerberos at the command line 
using the code in the tutorial:
  
http://java.sun.com/j2se/1.5.0/docs/guide/security/jgss/tutorials/AcnOnly.html 



I can not, however, figure out what I'm supposed to do to fit that 
part into the Catalina JAASRealm, as described here:
  
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/realm-howto.html#JAASRealm 



The first thing it says is "Write your own LoginModule".  
(Frightening... *I* have to talk to the Kerberos service?)  But 
there's already com.sun.security.auth.module.Krb5LoginModule which is 
used in the tutorial, so maybe not.  I have that in 
$CATALINA_HOME/conf/jaas.config with JAVA_OPTS set properly.


And that's about as far as I can get.  When I go to configure 
server.xml, it wants class names for users and roles:

 

Even if I write a couple of classes and fill in the blanks, I don't 
see what's ever going to instantiate them.


What am I missing?  This can't be as hard as I'm making it.

Thanks,
Wendy Smoak


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Certification

2005-08-11 Thread C.F. Scheidecker Antunes

javaranch.com


Rafael Taboada wrote:

Hi folks. I live in Peru and I'm so interested to get java certification. 
But here in Peru is a little difficult to have some courses in order to get 
certification and because it's so expensive.
 My question is u know some site or have some material in order to prepare 
myself for getting java certification. I was googling and all sites about 
preparing for certification exam request some money...

 Do u know some material or site about my doubt???
 Thanks in advance... And what about Oracle certification??? OCA, OCP, 
OCM...

 I'll really appreciate ur help

 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



JAAS vs JDBRealm

2005-08-11 Thread C.F. Scheidecker Antunes

Hello all,

A little question. I've wrote a little web app for school with Servlets. 
In my Eclipse Project I've added a context.xml file in order to 
configure JDBCRealm and it worked perfectly as Tomcat 5.x supports this 
kind of thing, adding a context.xml file inside the META-INF/ subdir.


In order to have the same kind of login functionality within Struts, 
that is 2 tables for Users and Roles could I just configure JDBCRealm 
this same way? Why would I bother using something like JAAS where I have 
to configure the JVM as well?


What are the advantages and disadvantages? JDBCRealm seems much easier 
to me.


Thanks for the input,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



The idea behind modules

2005-08-10 Thread C.F. Scheidecker Antunes

Hello all,

I was reading about modules and I wonder if anyone had ever used them.
As far as I can see by the examples, if you have different modules you still
run only one ActionServlet.

Hence modules seem to be useful only for group programming and bigger 
projects.

Am I right on this?

Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Avis.com J2EE website

2005-08-09 Thread C.F. Scheidecker Antunes

Hello all,

This is an interface question. www.avis.com is a J2EE/Struts website for 
what I can tell.
They have a nice feature to make a reservation which is the popup 
calendar they have for
the pick-up Date and Return Data. Would anyone know how could I have 
this kind of interface
for a user to select a date rather then using the drop down menus for 
Month and Day?


Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Setting and accessing Context and Session data

2005-08-09 Thread C.F. Scheidecker Antunes

Hello all,

More newbie questions. I just want to make sure I understand the idea on 
how to write a Struts application

properly.

How do you save something to the Session scope and then access it within 
Struts?

I pretty much understand how to do it within a Servlet.

How do you do the same for the Context? I also know how to do it in a 
Servlet.


Can a Model Class access or set anything in the Session or in the 
Context space?
Say that you want to access a database based on a parameter set on the 
Session?
Shall I make a getter for this model class and pass the parameter 
through an Action call or
can I access the Session data from a Model Class? Then I guess my Model 
Class should extend some

Struts class that would provide access to both the Session and the Context.

Are Model Classes instances unique for every Session? Or one instance is 
common to everyone?
I guess I am concerned with data state here and I just want to make sure 
how it works.


Thanks again!

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Application context bean

2005-08-09 Thread C.F. Scheidecker Antunes

Hello all,

I would like to have a bean with a data structure that gets populated 
when the application starts and then this bean is available to the 
entire application. The data structure will get populated via a data 
base. I need to call the database just once to populate the data 
structure. In case the database changes I would restart the server and 
have this bean populated again. Hence all the sessions can query the 
data structure within this bean. How can I achieve this?


Thanks in advance,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Category and Subcategory logic within Struts

2005-08-09 Thread C.F. Scheidecker Antunes

Hello all,

I need to have a set of categories and subcategories selection on a JSP 
page similar to what eBay has when you are selling an item.


When you select a main category the secondary category box is populated 
with options and so forth.


My first question is: How to organize that? Shall I have a data 
structure with a parentId field so that I can do a SQL select for all 
the items with that parent category?


Second question is: Shall I use some sort of data structure like a list 
of objects where the object is a representation of a Category and its 
fields such as CatID, ParentID, Name.


I guess I should have Javascript do the job as far as populating those 
lists for the interface. Are there any smart solutions to that? Is there 
any example on the web that anyone is aware of?


I am doing it for a parts web site where I am categorizing and 
subcategorizing the parts. I will have up to 4 levels of categories 
including the main one which is required, the other are optional.


Any ideas?

Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT]Terrific intro to JSF

2005-08-09 Thread C.F. Scheidecker Antunes

Well. It seems that all articles were written already.

http://www-128.ibm.com/developerworks/views/java/libraryview.jsp?search_by=nonbelievers:

[EMAIL PROTECTED] wrote:


Hi all:

i know it isn't Friday yet.. ;) but .. in case you have been looking for a 
nice and clear introduction to JSF, look no further. Here it is:


http://www-128.ibm.com/developerworks/java/library/j-jsf1/

I have only just completed the first article - and can't wait to get to 
the next three! - but the first article is just *fantastic*.  It's 
articles like these which make Java almost too much fun..:)


Geeta
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Displaying an image from a BLOB field on a jsp

2005-08-08 Thread C.F. Scheidecker Antunes

Hello,

Could anyone tell me how to fetch using a bean an image from a MySQL 
database blob field and displaying it on a jsp page?


Thanks,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Login with authentication from database

2005-08-07 Thread C.F. Scheidecker Antunes

Thanks Laurie!

I have quite a few Struts and Tomcat books. What I wonder is exactly 
where to set up JAAS. That's because I might have more than one app in 
the same Tomcat5 server. So I wonder if for each database/application I 
could configure JAAS separately, that is can I do it only within one 
Struts apps use a separate database,tables for that specific struts 
apps? If so what is the XML config file that I should have that? My 
struts-config.xml?



Laurie Harper wrote:


C.F. Scheidecker Antunes wrote:

I am learning my ways through Struts having done Servlets and JSPs 
before. In order to have authentication functionalities with my 
Servlets I used to have a user table and a roles table. Once the user 
logs in he/she would be authenticated with the user name, password 
through Tomcat as it was configured with the database information, 
table name, etc.


I would like to do pretty much the same with Struts. I have checked 
the O'Reilly Struts Cookbook but, although it has great 
authentication tips, it does not include a recipe to have 
authentication with a database. Is there any article on how to 
perform it with Struts? Any books that you would suggest?


So what I think is that I should have a model class to do this kind 
of authentication rather than using the XML config files. However how 
would I include all the roles in that class? Have a data structure 
like a list maybe? That way I could always check for a specific role 
for every JSP or action whether the user would be allowed or not. Any 
thoughts?



You can set up container managed security in just the same was as 
you've done previously, you don't need to do anything new or different 
with Struts (provided container managed security gives you everything 
you need). Once you have it setup you can tell Struts to restrict 
access to actions based on roles through struts-config.xml.


L.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Login with authentication from database

2005-08-07 Thread C.F. Scheidecker Antunes

Hello all,

I am learning my ways through Struts having done Servlets and JSPs 
before. In order to have authentication functionalities with my Servlets 
I used to have a user table and a roles table. Once the user logs in 
he/she would be authenticated with the user name, password through 
Tomcat as it was configured with the database information, table name, etc.


I would like to do pretty much the same with Struts. I have checked the 
O'Reilly Struts Cookbook but, although it has great authentication tips, 
it does not include a recipe to have authentication with a database. Is 
there any article on how to perform it with Struts? Any books that you 
would suggest?


So what I think is that I should have a model class to do this kind of 
authentication rather than using the XML config files. However how would 
I include all the roles in that class? Have a data structure like a list 
maybe? That way I could always check for a specific role for every JSP 
or action whether the user would be allowed or not. Any thoughts?


Thanks in advance,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Displaying a image from a MySQL Blob field

2005-08-04 Thread C.F. Scheidecker Antunes

Hello all,

I am writing a Struts application which needs to read a database, fetch 
an image inside a blob field and display it in a JSP page in two 
different ways:
- Within a thumbnail size inside a column of a normal html . 
Which means the image needs to be resized for displaying purposes.
All images inside this table cannot exceed a maximum height and width in 
order to have a neat display.

- And using the image original size.

Hence, I would like to ask if is there any example code on how to 
accomplish this task.
I guess the image size could be configured through html/javascript but 
what I wonder is how to read from the database and send it to the view 
component, the JSP

page to have it displayed.

I appreciate any inputs on this issue.

Thanks in advance,

C.F.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Newbie questions

2005-06-21 Thread C.F. Scheidecker Antunes

Hello all,

I am very familiar with Servlets, JSPs and custom Tags however Struts is 
a new beast to me. Hence I am studying to learn it.


What I would like to know is if anyone could point me to websites that 
would have recipes on how to code Struts such as phpbuilder.com for php.


What I would like to learn right now is how to get information from a 
Select statement from a database and display it on a HTML table. That 
is, first I have a search form
and them a search result with records from a MySQL database. I know how 
to do it with Servlets and JSPs but I would like to see a piece of code 
using the Struts framework.


What I also need is a navigation method. So that I can display 50 
records at a time. What I usually do is to have a limit on my select 
statement with a begining index and a maxium amout
of records so when I click on an arrow I call a get  method, pass the 
index and retrieve the next page of data.


Any good website or sample code you could recomend to me?

Thank you in advance!

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]