Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Select and unselect in textarea

 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Jsp code

 
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this


 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help. when i click on logout button cookies should be deleted and it should navigate to main page. and when i try to check the links of other pages it should not get displayed.  Is it possible to clear the cookies? I am going through the html tutorial for that.
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did the solution work?
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. The solution works like a charm.
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think just by removing cookies you will be able to resolve the logout issue.  You probably have to track the user session.
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply @Swastik. I just did it by disabling the back button. Now i am trying to send the mail notification when the user registers. Is it possible in jsp? Or i have to do java coding?
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ideally you should have the  registration and email notification in a servlet.
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Means in the jsp file where i am adding the new user.
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.  Putting java code inside jsp scriptlet blocks is not  wrong,  but it's not a very good practice.  Any controller or business logic should be inside servlet class. Jsp is ideally used to just represent the view.  
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i have to write the java code for sending mail notification. Am i correct? And i should use jsp just for the view.
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly yes.
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying with the following code.
Jsp code


Java code



I know the above java code is we have to type and send by ourself. But i want to send some static message that you have successfully registered with the username something like this.
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean we have to type and send?
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The above java code will display a separate page with 5 text boxes for username,password,message,subject and to whom. But i don't want that
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all the first part of the code (jsp) where you are retrieving user details, it self should have been a sevlet.  As we have said before jsp is just to produce the output to the user.  Any controlling logic should be within a servlet.  If you receive user details here, from this page itself you can call the SendMail class method.  You don't have to forward anywhere else.
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Means do i need to change my html and jsp page to single java class?
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my register page.
Html Code



The following code is for inserting the user



Here i am trying to send mail on submission of the form. Do i need to change the entire code to java?
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess i should do like this instead of using jsp.


From the above code how will i send mail to the registered user? I guess in the if condition i should write some code.
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting the following error

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: [30] in the jsp file: [/process.jsp]
SendMail cannot be resolved



I just added the two lines in my code

Do i need to add anything else?
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do i need to add something like the following code in my jsp file.

 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a JSP code, I thought that's servlet.  If it's JSP you have to import the SendMail class.
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Gayathri Gayu wrote:T
The following code is for inserting the user

Jsp code


Here i am trying to send mail on submission of the form. Do i need to change the entire code to java?

 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fair enough.  Where is your SendMail class?  Under what package it belongs to?  Post that entire class code with the package name, and the complete jsp code of the following

not just the part.
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SendMail class


JSP code


 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've also seen these issues on this blog
most different trip in mashhad
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should i specify the path for the import? Because i am getting the The import SendMail cannot be resolved error.
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As much as I remember, the import statement in jsp does not work if the class is not inside any package.  You first have to put the SendMail class inside a package for e.g mypack so your file should look like




 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did as you said. Now it is working But on submitting the form i am not receiving any mails.  Some error message i am getting instead javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8  https://support.google.com/mail/?p=BadCredentials f24sm1307199pjp.12 - gsmtp
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error is self explanatory.  Your gmail credentials you are using to send mail are not correct.



This user and pass parameters in the above method should be valid gmail id and password.
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The parameters you are sending to the send mail method doesn't seem to be correct, you have to send mail to the registered using your credentials.  So it should be

 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I should create the username with my mail id and my gmail id's password. Not with different password? Whether the user name i can create newly or it too should be the name i am using in my gmail?
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say a user called user1 is registering using your site.  He/she enters his userid as user1@gmail.com and password pass1.  So this password is actually the password for registration and has nothing to do with mail.  Now your next step is to send mail to user1@gmail.com using your gmail credentials.  So actual arguments passed to sendmail class is

To:user1@gmail.com
subject:<subject>
message:<message>
usr<yourgmailid>
pass<yourgmailpass>

 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the user can register with different password with their mail id. And the send mail class will send mail with some message. Is it so? So I should create one more class for sending mail to them. Am i correct?
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The above line of code will do the job? Sending mail to the registered users. Should i enter hardcode my maild id and password there
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you are still getting it wrong.  Your job is to send mail to the registered user and who is the sender it's you.  So why another class?  If you wish you can use my mailid as the user who is registering in your site and use any password you wish because that's not my mail password but password for registering in your site.  

SendMail.send(UserName<thisismygmailid the recipient>,"Registration Status", "You have been registered", <yourgmailid>, <yourgmailpass>);

After executing the code, let me know and I will confirm whether I got mail or not.

Yes your above code seems to be right.  You can even keep both same, in that case you will be sending mail to yourself.
 
Gayathri Gayu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I gave my gmail id and the password  
Still i am getting the error on submitting the form javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8  https://support.google.com/mail/?p=BadCredentials i71sm1559424pfe.103 - gsmtp
 
Swastik Dey
Rancher
Posts: 2162
15
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Might be something wrong with property settings in send mail class.  Let me look into it.
 
machines help you to do more, but experience less. Experience this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!