patt rich

Greenhorn
+ Follow
since Apr 07, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by patt rich

I believe the reason why we extracted the content out of it to string is because that was found as the easiest way to store in the database.
14 years ago
When I mentioned about saving the request and response, this is what I meant..

Before the HTTPServletRequest is sent out, I have got it in an inputstream and read it to a Stringbuffer. Then I made a string out of it and saved that string in the Database.
Now I decided to send the request object to a URL which is actually hitting a webservice and certain things are happening there.
So, the same way I got the request to a string, I am also expecting that I can get the response object and read that data out to a string and save that in the database.

Does that make any sense? Or am I confusing you guys more?
14 years ago
Thanks for taking interest in the topic.

My aim is to save the request and response in the database table for future reference actually. I store them as varachar in the SQLServer database.
14 years ago
I have a servlet. The request coming into the servlet has to be saved in a Database.
And the it has to be redirected to a URL.
After it's redirected, I want to get the response to a string which I should ultimately copy to a database.

I am able to :
get the request, save it in the DB, redirect to the URL.

I am not able to :
get the response to a string so that I can save it in the DB.

Any idea how I will do this?

Thanks for your suggestions.


14 years ago
I am not exactly sure how to aswer your thoughts from the first paragraph. Out of my 10 classes, each half is implementing different intefaces.

But about the second paragraph...
Before redirecting to another URL, I wanted use the request for other tasks like saving the request in a database etc. Also the URL is decided at run time. So i thought of doing all these specific tasks for each specific type requets, outside the servlet.

Since it's not recommended, now I decided to load the specific class reflectively, then save the request in DB etc, come back to servlet and do the redirect. Again call the specific class reflectively and do the rest of the tasks.

Anyway thank you so much for your suggestions. It was very helpful.
14 years ago
Ravi, I cannot use jsp page instead of a servlet because I need this servlet for many other reasons in the whole picture of the project.
Thank you

14 years ago
The reason for using Reflection :- Actually the name of the receiving class "receivingClassName" will be decided only at run time in my project. Out of my 10 classes which are available, anyone of them can be taken the value of this "receivingClassName".

The reason for forwarding the HTTPRequest-Response as it is : - In the method 'loadRequestData', I want to redirect this request to a different URL, where this URL is again fetched from outside sources like properties files, depending on the name of the class. That's why I am trying to send the request as it is:

So I guess you are not recommending to send the request-response as it is right?

Thanks for spending time on this.
14 years ago
I believe I am not taking the actual HttpServletRequest interface into account when I pass the parameter using reflection.

This is what I am doing:
In my servlet, I have the HTTPServletRequest and Response are available.

cl = Class.forName(receivingClassName);
Class[] classArray = { string1.getClass(),
string2.getClass(), request.getClass(), response.getClass() };
Object[] argVals = new Object[] {string1,string2, request , response};
Method method = cl.getMethod("loadRequestData", classArray);
objVal = method.invoke(cl.newInstance(), argVals);



And in my receiving class, the method "loadRequestData" looks like this:


public String loadRequestData(String string1, String string2,HttpServletRequest request, HttpServletResponse response) {
System.out.println("invoked successfully");
}

Looking at this do you think I am doing something wrong?
Thanks in advance for taking time to look at this..
14 years ago
"Are you doing a "getClass().getName()" on that object? That'll get you the the name of the implementing class, but it's still an HttpServletRequest"...

Yes, I load this simple class using java's reflection mechanism. So I do 'request.getClass()' .
That could be the reason why this is happening?
14 years ago
Ravi,
I have a servlet class. From that servlet class I call a simple java class since I need to do some specific things with the request. Meanwhile I also have to forward the request to another URL.

Do you know why this conversion is happening?
thanks for taking interest on my question
14 years ago
If I send a Javax.servlet.http.HttpServletRequest from a servlet to another simple Java class method as a parameter, it is received in the simple java class as 'weblogic.servlet.internal.ServletRequestImpl' Any idea why this is happening?

BTW, I have deployed the servlet in the weblogic server.

Thank you
14 years ago
Justin, I am using Kathy-Bert's book for 1.5 certification. And I guess this book is not for beginner. I like that book. At the same time I liked Khalid Mughal & Rolf Rasmussen's SCJP 1.4 certification book and that book is really good.
Anyway I guess I am leaning more towards taking 1.5 exam after hearing from you.

I am planning to take the SCJP exam sometime soon. I was preparing myself to take the SCJP 1.5 certification. Now that this book is going to be available, I am wondering if I should take the 1.6 certification. Any suggestions friends?

Thanks
I have a JSP page with a form inside of it. 'onSubmit' of the form, I want to invoke a java function with a value of the form.
I am adding part of my code here:

<form action="www.yahoo.com" id="hiddenform" name="hiddenform" method="post" onSubmit="<%getResponseValue(out.println("><script>this.ResponseType.value</script>"));%>">

<select name="ResponseType">
<option value="Default">Default</option>
<option value="Sucess">Sucess</option>
<option value="Failure">Failure</option>
<option value="Retry">Retry</option>
</select>
</form>

And here is my java function in the same file:

<%!String getResponseValue(String responseVal){
System.out.println("this is the responsevalue"+responseVal);
return responseVal;
}%>



Could you please let me know, why I am getting an error like below:
'void' type not allowed here
getResponseValue(out.println("<script>this.ResponseType.value</script>")); //[ /Admin.jsp; Line: 49]
^
1 error

15 years ago
JSP