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 Connection with servlets (jsp) 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 "Connection with servlets (jsp)" Watch "Connection with servlets (jsp)" New topic
Author

Connection with servlets (jsp)

Manish Khurana
Greenhorn

Joined: Jan 26, 2008
Posts: 23
I have a jsp program which accepts form data (username and password). I want to automate this and so I wrote a program to send the username and password as post requests .


The problem is how do i get the html otput and render it in the webbrowser.like mozilla.

[ February 29, 2008: Message edited by: Manish Khurana ]
[ February 29, 2008: Message edited by: Manish Khurana ]
Manish Khurana
Greenhorn

Joined: Jan 26, 2008
Posts: 23
I found out this code that starts the default web browser and opens the given web page in windows

String cmd ="rundll32 url.dll,FileProtocolHandler http://www.javaworld.com";
Process p = Runtime.getRuntime().exec(cmd);

but here its www.javaworld.com I need to instead display a dynamic webpage that the jsp returns.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

It's just making a web request.
It will display whatever the server returns (JSP ouput, PHP output, static HTML output). The browser has no idea if the content was generated dynmically or read from a static page.

Moving to our Sockets and internet protocols forum.
This really isn't a JSP issue.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Manish Khurana
Greenhorn

Joined: Jan 26, 2008
Posts: 23
you did not get my question. I have a program running at work place which is a hsp servlet that talks to database. I want to make a program that would automate the process of logging on by sending username and password and just display the page that is returned. so basically i just want some one to double clik on some icon on desktop that would talk with servlet send username and password and open a web browser and display the output. I do not not how to do this.
Manish Khurana
Greenhorn

Joined: Jan 26, 2008
Posts: 23
I added some more bits so now it saves the input in a html file and displays it in the browser. But the problem now is that response is not just a html file but some other picture files and other STUFF [edit: please watch your language] as well. I am stuckkkk.


[ February 29, 2008: Message edited by: Manish Khurana ]
[ February 29, 2008: Message edited by: Manish Khurana ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

"Manish Khurana", two things:

Please control your language.

And please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Manish Khurana
Greenhorn

Joined: Jan 26, 2008
Posts: 23
I am sorry it dosent work it dosent even send the login name and password via post. I get the html login form when i use this code. am i going about this the wrong way help appreciated
Manish Khurana
Greenhorn

Joined: Jan 26, 2008
Posts: 23
Can some one please help me about this. Maybe i have not explained the problem properly or am goin about it in the wrong way. I have at my work place a servlet running. What we do is that we go to the website a form comes up, we enter login name and password and we get another page where we can check up details about people from the database. What I wanted was some sort of automated login where we skip going through the login page and get straight to the details page. I am not sure if i use sockets instead or do something else.

I would appreciate any help
mudimala srinivasa reddy
Greenhorn

Joined: Mar 04, 2008
Posts: 4
1)As you said when you go to the website i think jsp executes and displays the logon.jsp page there you will be entering the username and password. and once you submit the jsp file then a servlet executes which validates the user and displays another jsp...if this is correct..

and you question is you want to by pass the logon.jsp file and directly you want to validate and display say welcome jsp..then for this

create a servlet class by name say logon.class and in web.xml you map this class to your url pattern.

in the servlet class you will get the request object. then set the request object with the username and password..as

req.setAttribute("username",your desired username);
req.setAttribute("password",your desired password);

now you redirect the request to the desired servlet which is validating the user details...

RequestDispatcher dispatcher =
request.getRequestDispatcher("user servlet calss file");

dispatcher.forward(request, response);

i hope this will work
mudimala srinivasa reddy
Greenhorn

Joined: Mar 04, 2008
Posts: 4
for forwarding request this also works....

RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher("your desired Servlet");
dispatcher.forward(request, response);
Manish Khurana
Greenhorn

Joined: Jan 26, 2008
Posts: 23
Thanks
But i do not have access to the servlet container or webserver. I can only write client side application
mudimala srinivasa reddy
Greenhorn

Joined: Mar 04, 2008
Posts: 4
Do you have access to web.xml this will solve...
mudimala srinivasa reddy
Greenhorn

Joined: Mar 04, 2008
Posts: 4
Do you have access to web.xml this will solve...
Manish Khurana
Greenhorn

Joined: Jan 26, 2008
Posts: 23
Nope I and the IT Manager do not get along very much so i am only limited to client side and so no web.xml
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection with servlets (jsp)
 
Similar Threads
Peculiar HTML Form INPUT Tag
show user credentials in target jsp which all are from swing form
Login to web server with HttpClient
error while submitting an http web request
post request to url