• 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

Calling a JSP from a Java class on the client

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I am trying to call a JSP page from a class sitting on client machine. Here is the scnerio:

o I have an OC4J instance (or any web/app server for that matter).
o There is a JSP page (say, test.jsp) deployed as part of a web app.
o I have an application or a Java class on a client machine.
o I want to invoke the test.jsp from this Java class and pass it some
binary data.

Any ideas on how to achieve this? I am not if I have been able to explain my problem clearly. If not, please let me know if there are any questions.

TIA,
Saeed
 
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

Originally posted by Saeed Amer:
and pass it some binary data.



This is the part that may be an issue. JSPs aren't "called" in the same way as methods. They are invoked via an HTTP request. So there's no "passing" of data except by using the HTTP protocol.

So by "pass it some binary data" are you talking about a file upload?
 
Saeed Amer
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your response, Bear!

I understand that JSPs are not called like methods and I thought of sending the binary data as a param (not sure if this is a good idea, or even a right thing to do).

I am looking at the "HttpURLConnection" but not sure yet if I'll be able to accomplish what I mentioned in original post.

> So by "pass it some binary data" are you talking about a file upload?
Yes, this is a "File Upload" task. The application is "Oracle Forms 10g application" running on Oracle App Server 10g and user has to be able to select a file from his/her local hard disk and send send it to an another application (Content Manager - running on some other app server) for storing.



Saeed
 
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

Originally posted by Saeed Amer:
I thought of sending the binary data as a param (not sure if this is a good idea, or even a right thing to do).



It's not possible. Parameters must be text.

Rather, you need to send a multi-part request that contains the data and necessary headers, in the same way that an HTML input element of type "file" would. Formattng such a request could be a bit tricky.


I am looking at the "HttpURLConnection"



That would be one way to do it. But you'd be reponsible for a lot of detail in generating the request. I'd suggest taking a look at the Jakarta HttpClient project before diving off into perhaps re-inventing the wheel.
[ November 16, 2006: Message edited by: Bear Bibeault ]
 
Saeed Amer
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

Thanks again!

It's not possible. Parameters must be text.



Please forgive me for my ignorance but I read some where that through POST request, binary data can be sent (now, I am not totaly sure of the context - maybe it was regarding a Servlet, though a JSP also ultimately runs as a servlet). That was in my mind when I though on these line. How can I use the "POST" method to send data to JSP (if at all)?

OK, as you have suggested, I'll look at the Jakarta HttpClient stuff.

Thank you once again!

Saeed
 
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

Originally posted by Saeed Amer:
that through POST request, binary data can be sent



Yes, by way of the multi-part request that I already mentioned.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're wanting to send binary data via HTTP from a java class, I would recommend you look at the jakarta commons HttpClient library.
http://jakarta.apache.org/commons/httpclient/

Pro: It will help you do the upload with a minimum of fuss.
Con: The support libraries you need to install for it.
 
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

Originally posted by Stefan Evans:
If you're wanting to send binary data via HTTP from a java class, I would recommend you look at the jakarta commons HttpClient library.



Yes, as I had already recommended.
 
Saeed Amer
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Bear & Stefan!

I am working on it using HttpClient as suggested... I hope I'll get it done...

Regards,
Saeed
 
What are you doing in my house? Get 'em tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic