File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes JSP Submit from java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "JSP Submit from java code" Watch "JSP Submit from java code" New topic
Author

JSP Submit from java code

Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 146
Hi all,

I wonder can some one help me here? Basically i have a very simple jsp page which on a submit press will forward an email address to a servlet which does processing on the email address which all works grand when the button is pressed manually.

Now so want im trying to do is perform a java http post to the web server on
my computer from a simple java app, the java app builds the address and
parameters then does a http post which works but the actually jsp does not do submit, all i get back on the in stream from the http post is the jsp contents and not the results that would have occurred if the jsp had submitted the info to the servlet my java app posted to it.

Its like my address is built ok but all it makes the jsp do is a refresh and not a post. If ya get me?



Above is what i send on the http post, Does anybody know how to make my JSP submit to the servlet from java code?

Best
Mark
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Your question is a bit confusing. What are you trying to do ?

a. Submit to the servlet from a JSP
b. Submit to the servlet from a java standalone app
c. Submit to the servlet using a JSP from a standalone app

option c actually does not make sense but I am just trying to figure out what you want to do. You can submit from the JSP using the 'submit' input type or my using javascript to submit your form


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 146
b. Submit to the servlet from a java standalone app
c. Submit to the servlet using a JSP from a standalone app

I guess option b is ultimately what i want to do but i did not know a stand alone app can communicate with a servlet, i thought only a jsp could do that which is why i was trying option c.

stand alone app communicates with a jsp which communciate with a servlet.

The jsp works by communicating with servlet but i want it to be automatic so a user will never actually see the jsp page or servlet, only use a standalone java app which talks to a server.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you want to submit to a URL from a standalone Java app, look at
URLConnection.html and its subclasses.

There is also a higher level Apache project that could save you some coding
http://jakarta.apache.org/commons/httpclient


Since this is no longer about JSP, I'm going to move it to our Sockets and Internet Protocols forum.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 146
ok thanks ill look at them.

best
Mark
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSP Submit from java code