• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to pass data from jsp to java class file without using servlet

 
Ranch Hand
Posts: 136
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Am trying to send a file from jsp like this,

My java class is,

How can i get the data from the jsp file to java class without using the servlet. Kindly suggest me an idea.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The concept you're looking for are "JSP backing beans".
 
Sabarish Venkat
Ranch Hand
Posts: 136
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP Backing beans :confused: am hearing this name first time. What this means could you explain me brief.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What did you find when you searched for the term?
 
Sabarish Venkat
Ranch Hand
Posts: 136
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing i found related to it to my search. This is only i got JSP backing bean but this too not related.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see, many JSF-related results. Try "jsp backing bean -jsf" at Google. It'll lead you straight to the relevant JEE chapter.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forms should always be submitted to servlets. Why are you trying to avoid this best practice?
 
Sabarish Venkat
Ranch Hand
Posts: 136
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Bear - Am using a third party API program that is purely java classes i want to send data to that function. Since we cant send request parameter directly to java class without using servlet am trying an alternative way to achieve it. Is there any solution bear.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not without writing your own server. Why can't you call the API from servlets?
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sabarish Venkat wrote:Since we cant send request parameter directly to java class without using servlet


You are not passing request parameters, you are passing a file right?
Next technically there is no difference in the functionality a JSP and servlet perform.
You can instantiate the class and read the file directly from the JSP. I don't see this as a good implementation though.
Have you thought of thread-safety?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amit Ghorpade wrote:Next technically there is no difference in the functionality a JSP and servlet perform.


I will strongly disagree. The fact that JSP is implemented as servlets is an implementation detail. JSP has oodles and oodles of extra functionality that is not present in servlets.

However, if your point was that anything the OP thinks he can do in scriptlets in a JSP can be more easily (and properly) done in a servlet, then I 100% agree.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:However, if your point was that anything the OP thinks he can do in scriptlets in a JSP can be more easily (and properly) done in a servlet, then I 100% agree.


Yes Bear that's exactly my point. I am not able to understand why the OP is ignoring servlet for this purpose.
 
Sabarish Venkat
Ranch Hand
Posts: 136
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As i thought of calling API through servlets in have to get all the functionality that present in API. It will be difficult for me to find each and every functions that are doing some internal operations of API. So i dont want to repeat the same API as servlets or calling it as servlets
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sabarish Venkat wrote:As i thought of calling API through servlets in have to get all the functionality that present in API. It will be difficult for me to find each and every functions that are doing some internal operations of API. So i dont want to repeat the same API as servlets or calling it as servlets


I don't really understand what you are trying to say here, but regardless, you're going to have to use servlets to respond to the requests.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So is I understand this right:
- you have a 3rd party application.
- You want to write a web application front end to invoke that application, because it doesn't have a web front end.

Not knowing anything about the app you are invoking, what sort of parameters it takes etc makes it harder to answer the question.
Because you are passing up a file, I presume this 3rd party app requires a file as input.

Writing a servlet to handle the requests IS the obvious thing to do.
It should act as the bridge between the HTTP request and the API call, translating as necessary.

That means that yes, for each API call in the 3rd party app you want to handle via the web, you will have to invoke it from the servlet.
In essence your servlet becomes a dispatcher to go
- read the request
- invoke the business logic (3rd party app)
- provide a response???

Depending on the API, you should be able to make a generic dispatcher servlet that will serve 95% of use cases.


 
Sabarish Venkat
Ranch Hand
Posts: 136
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Stefan Evans - Exactly you got my problem. The Third party API link is here Zencoder - API for Java . This zencoder is and video and audio encoder API where the input files will be converted into different formats as the user wish.

For more details about it you can see this link. Zencoder
reply
    Bookmark Topic Watch Topic
  • New Topic