Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection with servlets (jsp)

 
Manish Khurana
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Manish Khurana
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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 .
 
Manish Khurana
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for forwarding request this also works....

RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher("your desired Servlet");
dispatcher.forward(request, response);
 
Manish Khurana
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
But i do not have access to the servlet container or webserver. I can only write client side application
 
mudimala srinivasa reddy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have access to web.xml this will solve...
 
mudimala srinivasa reddy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have access to web.xml this will solve...
 
Manish Khurana
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic