Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Shwetha Sharma

Ranch Hand
+ Follow
since Jun 01, 2008
Shwetha likes ...
Eclipse IDE MySQL Database Java
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 Shwetha Sharma

I am new to Spring web services. My web xml has

My wsdl is generted on the following url : http://localhost:8080/MyProject/services?wsdl
I get the xml response of one of my service methods by http://localhost:8080/MyProject/services/getStudents
The getStudents method return an array of StudentBean which is displayed in xml format by the web service
StudentBean has the folowing attributes : name, class, height, weight, isMember
I want to display isMember as a attribute of student node, nut currently it is is showing as an element of student node
i want to include a schema which i have made to customize my student node in the response of my web service.
How can i do this?
9 years ago
I missed the difference in usage.

If we dont specify the class attribute for the jsp:use bean, then Instanciation Exception is thrown in case the bean is not present in session or its null




results in



and in case we give class attribute


results in


In servlet if we have


jsp code :


In the generated servlet:


Runtime exception is thrown



and in case we have something apart from null in the request attribute:


the generated servlet has:


Why the null condition has diffeent behaviour in both cases in the generated servlet?

Bear Bibeault wrote:
The same method used to put imags into an HTML page must be used with JSP; in other words, an <img> tag, whose src can be a servlet (not a JSP) that streams the image data.



Thanks it worked.
I used the image src as servlet that streams a image data
10 years ago

seetharaman venkatasamy wrote:
Use Servlet . dont do this stuff in jsp



Actually my doubt is in a jsp since we can use the out object to write to the current stream, what coud be used in the included jsp to contibute in the response if the included jsp is creating a dyamic content and want to write it to the main jsp.

As in my case i am dynamically creating an image and want to include that created image in the main jsp. I am not doing this job in the servlet method as it is already getting some dynamic content from the database and storing it in session.Then it is forwarding it to the main jsp in which i want to show my dynamically created image.
I am not writing any content to the response in the servlet method so I have done this stuff in the included jsp.

Any help would be appriciated
10 years ago
This is the code fragment from the included jsp.
This jsp is intended to write an image (jpg) to the main jsp



Exactly the "response.getOutputStream()" is throwing the IllegalStateException


java.lang.IllegalStateException
at org.apache.jasper.runtime.ServletResponseWrapperInclude.getOutputStream(ServletResponseWrapperInclude.java:63)
at org.apache.jsp.captcha_jsp._jspService(captcha_jsp.java:192)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
at org.ap



Can someone help me on this?
The jsp is included through <jsp:include page=....></jsp:include> action
10 years ago

a.When we override init(ServletConfig config) method in our servlet then is it mandatory to call super.init(config) from within it ?


No it is not mandatory but the servlet initialization (which includes creating or loading objects that are used by the servlet in the handling of its requests, ability to log events, use its ServletContext refrence etc) is done in the Servlet's init method.
So if super.init() is not called the the class will not get its servletness.

b. If it is mandatory then why my sample servlet ran fine (without giving any error) ?


Your code ran fine because you just flushed some html code to the Response' PrintWriter.
Say for eg if you tried making use of the servlet parameters using Servlet Config object then the code would have thrown a exception.
Say in the doPost method you want to use the servlet paarmeter "NAME"


web.xml

This would have resulted in a exception as config object wasn't initialized since super.init() was not called.So getServletConfig() returned null and calling config.getAttribute("NAME") will result in NullPointerException.

c. What are the implications of
i. calling super.init(config) from within init(ServletConfig config) method in our servlet
ii. not calling super.init(config) from within init(ServletConfig config) method in our servlet



To make use use of the actual servletness of a servlet, it is required to call the super.init() in the overridden method.


PrintWriter.println(String)
This method prints null if the argument passed to it is null.

PrintWriter.write(String)
This method throws a null pointer exception if the argument is null.

Apart from this it works the same as the write method except that it appends "\n" to the string argument.

Also the println method throws IOException while the PrintWriter.write doesn't throw IOException
If we make JSP files not depend on Servlets, we may want to expose the JspContext object, not the PageContext object.
Can someone explain what does the above statement means.
When does " JSP files not depend on Servlets" ?Arent all jsp files going to get converted into servlets everytime


Give me the fragment from the specs about that.



This is the fragment from the speculations

Objects are created within a JSP page instance that is responding to a request
object. There are several scopes:
page - Objects with page scope are accessible only within the page where they
are created. All references to such an object shall be released after the response
is sent back to the client from the JSP page or the request is forwarded somewhere
else. References to objects with page scope are stored in the pageContext
object.
request - Objects with request scope are accessible from pages processing the
same request where they were created. References to the object shall be released
after the request is processed. In particular, if the request is forwarded
to a resource in the same runtime, the object is still reachable. References to
objects with request scope are stored in the request object.
According to Jsp speculations,
All references to page scoped objects shall be released after the response is sent back to the client from the JSP page.
References to the request scoped objects shall be released after the request is processed.
Aren't all page scoped objects withing the request scope.
I am not able to make out the exact difference between them.
I am a newbie to grails framework and groovy.
I have an experience of making web applications with struts, spring and hibernate.
Can grails be used as a complete replacement for these frameworks for building enterprise applications, web services, desktop applications.
I want to learn groovy and grails starting with their basics and am planning to read this book as soon it is available.
Can the book be taken a start guide for grails or you recommend some other resource before picking up your book.
10 years ago
Welcome back Charles Lyons.Thanks for the info
Today I cleared SCJP 6 with 80%

Thanks all the ranchers for their support and help.

JavaRanch rocks!!!
11 years ago