Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

class via a call button?  RSS feed

 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to call a class (which has a method to record in the database) by mimha jsp, but I can not.

my code that has a button is this



..
<td>
<a href="<c:url value="download/send?" >
<c:param name="arquivo" value="${row.file}"/>
<c:param name="pathname" value="${row.path}" />
</c:url>">
<img src="images/pictgure.jpg" width="20" heigth="20"/> </a>
</td>
..


Anybody?

Thanks
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The simplest and basic way to do this as below :
1) Post the data that needs to be added to the database
2) You can either choose to post to a JSP or Servlet if you are using plain JSP-Servlet architecture (MVC 1 or 2)
3) In the JSP or servlet invoke the corresponding method of the class that does the task to insert the data in database.

regds,
amit
 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
amit punekar wrote:Hi,
The simplest and basic way to do this as below :
1) Post the data that needs to be added to the database
2) You can either choose to post to a JSP or Servlet if you are using plain JSP-Servlet architecture (MVC 1 or 2)
3) In the JSP or servlet invoke the corresponding method of the class that does the task to insert the data in database.

regds,
amit



Hi,

Thank you for your cooperation,

I'm kinda lost it, below is my code.

The intention is that every time someone clicks the button it writes to the database id of the person and date.

jsp


Classe



Can you help me with some idea or example?

thanks
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can not directly call the class from a JSP like that. I am assuming that "dowload/send?" is the kind of URL you want to use to invoke the class "logDownload ".
What you need to do is that write a Javascript function that would get executed when you click the button. In this Javascript you can post the data to a Servlet. Now there are two options ..either you can convert your "logDownload" class into a servlet or write a new Servlet that will call "logDownload" to do its task.
Again this is a very crude way to do the things but might be helpful to you to get the things running first. After you study some more tutorials on this topic you can re-factor it.
If you need example any JSP-Servlet tutorial can help you do this. I do not have any at the moment that I can share with you.

Regds,
Amit
 
fabio alonso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

So Amit ,

According to his idea, then it would be better to create a new servlet and create a javascript code in my jsp?

Regds,

 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
That's correct. You need a servlet on the server side to listen to the requests originating from your HTML page.
Once you are done with this you can think of doing this asynchronously using Ajax. There are number of ways to implement this based on different business requirements.

regds,
Amit
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fabio alonso,
Your post was moved to a new topic.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!