Luis Villamarin

Greenhorn
+ Follow
since May 24, 2012
Luis likes ...
Android Chrome Java
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
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Luis Villamarin

I'm trying to user Apache Commons Streaming API to get the information from an excel spreadsheet. I keep on getting the following error:


This is the code of ReportServlet that process the information:

[/code]
I'm using glassfish. Any ideas why I keep on getting this message?
I'm trying to get my login form to with a MySQL Database and keep on getting the following error:

WARNING: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception
WARNING: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception
WARNING: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception


That's all I get from the stack trace. I'm following this tutorial: http://blog.eisele.net/2011/01/jdbc-security-realm-and-form-based.html

This is my mapping on glassfish-web.xml:



This is my web.xml:



This is my login form:



This a screenshot of my realm setup in the server. I didn't use encryption to simplify things for the moment:


Since I have nothing else in the stack but what I posted above. I'm really not sure what's wrong. I would appreciate if anyone can me a push in the right direction.
Problem solved. I had to update Netbeans to 7.2 from 7.0 and solved the issue, now I was able to add the file from add new file > Glassfish > Other > glassfish-web.xml / xml descriptor.


I know that this is the servlet forum but I didn't find the Glassfish/Netbeans related to this issue.

I'm currently trying to set up a secured folder with a few pages within my Java Web App to allow only registered users to access the pages in that folder.

However, while trying to do the setup/mapping of the groups I have been having the issue that the sun-web.xml is missing. I'm using Netbeans IDE.

Any ideas why this happened and how to fix it? I've done research and haven't really found a solution for the issue.

Thanks in advance


That suggests to me that the security constraints are preventing the CSS from being downloaded. Have you done some browser debugging to see whether that is the case?



I debugged and found that the css is not being downloaded. I'm new to Java Web development would you be able to let me know how to enable the css to be download to the app when it accesses the pages in the secured folder?

Thanks in advance.



9 years ago
JSP
Hello,

I'm having a silly problem with my css and one of my jsps. I created a restricted folder where people who are registered only can access the pages inside.

For some reason the CSS disappears when I go to any of the pages inside the secured folder, the login.jsp (located outside the secure folder) or login-error.jsp (also outside the secure folder).

I've tried using absolute and relative links to link back to the CSS but still none seems to work.

If I remove the security constraint then everything start to work again.

Any ideas on how to solve this?
9 years ago
JSP
Jeanne and Chris,

Thanks for the responses.

@Chris - I used MySQL Workbench to create the DB and I have three tables that come into action for the problem that I'm presenting. The field account_type_account_name is the name of the 'account_name' in the table 'account_type'. Therefore the field is account_type_account_name is a FK in the account table (which is the one I'm trying to populate).

@Chris and @Jeanne - The User table PK is emailAddress, and the Account table PK is account ID which generated using java.util.UUID, and the account_type table PK is account_name. The account_name is FK in the account table and the emailAddress is FK in the account table. The account_type table already has information stored in it. For the moment the account_type table has only 3 Rows.

I have worked the insert method and I added some other fields and referenced the fields that were missing. This is how it looks right now, however the 2nd table is still no populated with data after the form was filled. It is not giving me any stacktrace.

Thanks for the response. I have followed your suggestions however the application still only saving information to one table. Would it make sense to create another class for the second time?

Here is an updated version of the code:

I have two different tables in a MySQL DB. I have successfully inserted data to to the parent table. However, I 'm having problems to the second table which has the FK from the first table.

I'm new to JDBC and haven't been able to find documentation on how to add data to two tables using the same insert method. I suppose I have to use two different preparedStatement within the same Insert method but I'm not really, plus it doesn't work.

Any ideas on how to solve this where I can research to find the solution.

This is my insert method:
Hey Wendy – Thanks for the suggestion. I thought there was something specific to servlets to pass int values.

I solved the issue using the regular Integer.parseInt.

In case others have the same question this is what I did:


Thanks again.

Hi I worked on the database and effectively there was a relationship that was not correctly set. However, what I did, didn't fully fixed the problem this what I'm getting now as an error:


SEVERE: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`ebooksalesdb_schema`.`user`, CONSTRAINT `fk_user_account1` FOREIGN KEY (`account_account_id`, `account_account_type_account_name`) REFERENCES `account` (`account_id`, `account_type_account_na)

I noticed that at the end of the error it says `account_type_account_na, instead of `account_type_account_name'). I checked for the name inconsistency and couldn't find anywhere that `account_type_account_na. Could this be the reason ?


I rebuilt the database and I'm still getting the same error.

Do you have idea why this keeps on happening?
Could this be that the FK was not properly created when the DB/Table was created?
Hello,

I'm trying to store data to from a registration form (html). everything runs smoothly until I try to store the the Foreign Keys. When I test the form I get the following error:

SEVERE: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`ebooksalesdb_schema`.`user`, CONSTRAINT `fk_user_account_type1` FOREIGN KEY (`account_type_account_name`) REFERENCES `account_type` (`account_name`) ON DELETE NO ACTION ON UPDATE NO ACTION)

After running the application the stack trace indicates that the error is located at:
at eBooks.data.UserDB.insert(UserDB.java:47)
at eBooks.controller.RegisterUserServlet.doPost(RegisterUserServlet.java:71)



This is the code for the RegisterUserServlet:



This is the code for the UserDB class:
Kunal thanks for the response.

I have changed that to a string now. However, I would still like to ask you how to pass an integer from form to a servlet to a DB?

Thanks in advance.

Luis
Hello,

In my database I have a int field called accountType. The data to be stored in that field is coming from select element (html) with different 3 different options as follows:


I have a servlet that gets the parameter from the html elements. For a string I know I have to use something like , However I'm a little confused about how to get the selected option value as an int so I can store it as int using a DB class.

I will appreciate any suggestions on how to approach this.

Thanks in advance.