nirali shah

Greenhorn
+ Follow
since Apr 16, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by nirali shah

Even an instance has to be created.

Session session = new Session();

this creates an instance of Session object and session is the reference for this object. After this we can access properties of Session. If Session and PageContext have a method by the same name, then how to access it ? How would I know, an instance of Session is referred by what name and an instance of PageContext is referred by what name ?

As David replied that these objects are alredy instantiated. What reference is pointing to these instances ?

15 years ago
JSP
There are implicit objects like request, response, session, out, Page Context etc available for use.
These objects can be used directly and instantiation takes place automatically. If a method by the same name is existing in both the classes, which one would be invoked eg session.getAttribute(String name) is in Session and PageContext both the classes. session is reference which can be used with any object. So in this situation when
${session.getAttribute("name")} is used in jsp, which class will be instantiated , Session or PageContext ? session is reference or classname ? I tend to assume that session is referance name in here because it starts with lower case "s". Classname starts with uppercase "S". If session is classname in here, why is it starting with lower case which is contrary to convention.

Please explain this in detail , how does instantiation of implicit objects work.

thanks
15 years ago
JSP
Whats the difference between EL and JSTL ?
Where can I find details about how to use EL ?

Can someone please explain in details about EL ?

thanks
15 years ago
JSP
I was going through head first servlets & jsp book on page no 295.

I came across this example, in which count is initialized in expression now count is incremented by one. Next time it comes in the loop, it again is assigned with zero. Since the variable declared in expression becomes local variable.

Now the same variable count is declared in declaration. So it becomes class variable. Now this variable count is accessed in the local method. Now the question is how can a variable be initialized at class level , unless its a static variable. The variable show in example is not declared as static (As its in a servlet which is derived from jsp page). So does a variable declared in declaration automatically become static ?

thanks
15 years ago
JSP
I just need one to start work with. I did visit jakarta's page and downloaded from there. But there was no documentation of anykind. I have provided details below of my download.

this is what I see on jakarta's page

"Download a binary distribution of the Standard release:

Download the Standard Tag Library Release from an Apache Jakarta Project Mirror
Download the most recent, nightly snapshot:

Standard Taglib nightly snapshot
Nightly build distributions of the development version for all the Jakarta-Taglibs are available for download:

Download Jakarta-Taglibs Source
Download entire Jakarta-Taglibs Distribution "

which one do I download ? I tried one under that Apache Jakarta Project Mirror. Is that right one ?
Or shall I download Jakarta-Taglibs Source or Jakarta-Taglibs Distribution ?

Can you please provide exact path on jakarta's site, about from where to download and once downloaded what will be the path for specification.


thanks
15 years ago
JSP
I did visit the link provided by you, but I am still unable to figure out. That link directed to other link.

I visited java.sun.com. In that I looked for taglib and I found that java WSDP is having a taglib as a part of the package. Now this java WSDP and jdk are one and same or different ?

To download taglib alone, I visited brothersoft.com and downloaded a package from there. There were few tags like NextPageButtonTag, NewPaneTag etc. But I could not figure out how to use these tags. I could not find and specification document mentioning how to use these tags.

Can someone please provide detailed answer to my problem rather than being brief and directing to other sites please.

I visited http://www.javaworld.com/javaworld/jw-02-2003/jw-0228-jstl.html?page=1 , from there I clicked on the link "Download the JSTL archive", that directed me to "http://apache.towardex.com/jakarta/taglibs/standard/"
this page is not being displayed and gives error message "Internet Explorer can not display the webpage."

thanks
15 years ago
JSP
how to find what taglibs are made public by the author ? How to find them ? Is there any centralised store there to store the taglibs like APIs are available online through java.sun.com ?

You replied earlier to check JSTL sprcification. Can you please tell where and how ? Is there any command line tool to check jstl specification like javadoc ?

thanks
15 years ago
JSP
thanks. Thats the logic I was applying.

Question is, how do I know which tag does what ? If I want to use an API, I can refer to the documentation on java.sun.com and find the details of API. These APIs are available to anyone who wants to use it.

Where can I find documentation for the taglib ? Are they available to everyone ?
The tags you used in the example you gave, if I want to use those tags what do I need to do ?

I have no idea where to start from for the use of taglib. Can you please explain where to start ?

thanks
15 years ago
JSP
I have tomcat installed on my laptop. Now I am trying to understand taglib. So I checked almost all the folders under tomcat and found "jstl" in the following path
"C:\Program Files\apache-tomcat-5.5.27\webapps\jsp-examples\WEB-INF\lib"

jstl is jar file, I opened it with winzip and I found few classes organized in different folders placed in a hierarchy e.g. one class is "ConditionalTagSupport.class". Do these classes represent tags ? If yes then How to use these tags ? How do I know what does this tag do ?

If its not tags, then where can I find some sample tags ? Are there readymade tags library available or all the libraries are custom made by organizations ? Is it proprietory information ? Is there any sample tag library available to work with ?

thanks
15 years ago
JSP
<%@ include file="somePageOfText.ext" %>

"The directive tag instructs the JSP compiler to merge contents of the included file into the JSP before creating the generated servlet code. It is the equivalent to cutting and pasting the text from your include page right into your JSP. "

This includes file somePageOfText.ext in the page. Question is, does it get the content in the page before starting the execution of jsp page ? So no matter where include directive is in the jsp code, it will be executed first and content if the included page will be pasted at the top of the page and whatever is the output of the generated servlet code will be attached to this included file content. Is this correct ?

----------------------------------------------------------------------------

<jsp:include page="someJSP.jsp" />

This action directive, whenever encountered in the code, will execute this code and put the content in the original jsp page at the location where this include action is placed.
Does it mean that <jsp:include ...... /> can be placed anywhere in the jsp code ? I have seen this "include" action always at the beginning of the page.

The only difference between action and directive is that directive can be placed anywhere in the code but it will be executed first and its content will always be at the top of the page. It can include only static page. While in case of include action, it can include dynamic pages and its content will be placed at the location where its placed.

Please correct me whereevr I am wrong.





15 years ago
JSP
what are the six standard actions in jsp ?

When I see a tutorial in one it mentions jsp:useBean , jsp:setProperty and jsp:getProperty, jsp:include, jsp:param and jsp:forward. In another tutorial there are few more like jsp:fallback, jsp:plugin and may be more.

So are not the scriplet, expression, declaration and directive action tags ? what are these tags called ?

What other tags are there apart from action tags ?

thanks
15 years ago
JSP
Can you please elaborate more ?

1 without any values in the request, how the java code will be executed ?

2 why will the execution not throw any error ? Is there some default value inbuilt in the values required ?

3 Once the user provides username and password in the html page created because of the earlier request, will the next request again invoke same jsp ?

Please explain with some more details

thanks
15 years ago
JSP
Following is the jsp page, which is rendered when client contacts the server for the page (Usually it should be HTML page). In this jsp page , there is java code which requires info from the client to be filled in the fields and that info is processed on the server. Now when this page is rendered at the first request only, there is no info available from the client as yet. So how will java code in jsp be executed (String userName = request.getParameter("username"); String password = request.getParameter("password");) ? Since there is no object available, will not it throw null pointer exception ? If no, then why not ? where will the values for username and password come from ?

----------------------------------------------------------------------------------------------------

<%@ page language="java" import="java.util.*" %>

<%
////////////// get the login information:
String userName = request.getParameter("username");
String password = request.getParameter("password");

////////////// and save it in the session:

session.setAttribute("username", userName);
%>

<html>
<body>

Welcome, <%=userName%>!
<form action="..." method="get">
....
</form>
</body>
</html>

--------------------------------------------------------------------------------

thanks
15 years ago
JSP
This question has been reposted for easier reading.
following code I have taken from an example



we are using bean instead of putting logic in the jsp page.

But, we should first create the 'player ' bean with all the attributes and getter & setter methods, as shown.



How is the values of parameters a, b and c is passed to the setName(String a), setPlace(String b) and setGame(String c) from the form without {param.text} ? If the values are passed from the form using {param.text} , then why not use that directly in the jsp page rathet than calling it through bean ? What is the use of bean in such a situation ?



Whats the need of getter methods, when all the variables are public and can be called directly ?

In this demo2.jsp, we collect the data and then display the data entered by the user. Question is, how is data sent to the bean from the form ?

Note that instead of {param.text1}, we are using {bean1.name}. We should carefully name the html form controls with the corresponding attribute names given in the bean. We cannot name the controls as 'text1' etc, now! Question is, we can use {bean1.name} in the jsp page and collect data from bean1 in the jsp page. But how does bean1 get parameters from the form ?



why use ${bean1.name} ? We can directly get parameters from form as ${param.text} ? Whats the point in using bean in this situation ?

thanks
15 years ago
JSP
This question has been edited for easier reading.
following code I have taken from an example


<jsp:useBean id="bean1" class="ourbeans.player" > <jsp:setProperty name="bean1" property="*" /> </jsp:useBean>

we are using bean instead of putting logic in the jsp page.

But, we should first create the 'player ' bean with all the attributes and getter & setter methods, as shown.



// player.java package ourbeans; public class player{ String name; String place; String game; public player(){ name=" "; place=" "; game=" "; } public void setName(String a){ name=a; } public void setPlace(String b){ place=b; } public void setGame(String c){ game=c; }

How is the values of parameters a, b and c is passed to the setName(String a), setPlace(String b) and setGame(String c) from the form without {param.text} ? If the values are passed from the form using {param.text} , then why not use that directly in the jsp page rathet than calling it through bean ? What is the use of bean in such a situation ?



public String getName(){ return name; } public String getPlace(){ return place; } public String getGame(){ return game; } }

Whats the need of getter methods, when all the variables are public and can be called directly ?

In this demo2.jsp, we collect the data and then display the data entered by the user. Question is, how is data sent to the bean from the form ?

Note that instead of {param.text1}, we are using {bean1.name}. We should carefully name the html form controls with the corresponding attribute names given in the bean. We cannot name the controls as 'text1' etc, now! Question is, we can use {bean1.name} in the jsp page and collect data from bean1 in the jsp page. But how does bean1 get parameters from the form ?



why use ${bean1.name} ? We can directly get parameters from form as ${param.text} ? Whats the point in using bean in this situation ?


thanks


15 years ago
JSP