Naveed Ali

Ranch Hand
+ Follow
since Aug 30, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Naveed Ali

Ben,

IE: You will not be able to pass objects using request scope if you are using sendRedirect because you will be working with a new request in the next JSP.

Don't understand why can't we pass objects using request scope. Can we do
it using jsp:forward? If yes, what is the difference ?

Naveed
[ September 09, 2005: Message edited by: Naveed Ali ]
19 years ago
JSP
Hi all,

Can we pass variables declared in one jsp as parameters in request(through 'jsp forward' or 'sendredirect') to another jsp. Actually in my case i have an array list/or it may be 'map', that i want to pass to another jsp through 'jsp forward'. Also i need to know that can i store them in a session so that i could get it in another jsp.? Thanks in Advance.

Naveed
19 years ago
JSP
I am working on a web application in which user enters certain data after which he is redirected to some another application outside of the current context by providing the relevant URL. After it fills cerain in that application, that application redidrects it back to my application with certain results for the user as appended parameters. Now the problems is that user had been loged out and its session has been terminated and also there are some other objects which are not accessable. But still i want to get those new parameters(data) for the user and update the database. How it is possible ? What are the possible solutions ? Actually the user has its unique ID which the user when loged out is no longer available to me.

thnx.

Naveed
19 years ago
JSP
Hi all,

I open a login page of my application, if one is a new user then he/she clicks on 'register' link to be registered. After providing sufficient informations on the registration page and after passing validation rules new account is created.

Problem: The problem is when a user is registered then i use javascript to go back to the previous login page with new user Id/password and after applying certain security rules the user is entered into the application but with the main screen/window appearing TWICE (the problem). Also Id/password is appeaeing in the address bar appended to login page.

Can any body answer where may be the fault. The JavaScript part of the .jsp is,

<script language="JavaScript">
if (document.getElementById("_status").value == "Updated"){
window.location = "login.jsp?userid=" + userid + "&password=" + password;
}

</script>
Hi all,

Can we declare mehtods in bean other than the standard naming convention(getter/setter) and call these mehtods in our jsp. If yes then it means that we can create a bean without any getter/setter mehtod. How it is?

thnx

Naveed
Hi All,

What about string concatenation by using the '+' operater. Does it creates new string objects?.

Example:
String str1 = 'frist name'
str1 = 'frist name' + 'last name'

My qustion is what is the number of objects after concatenation?
Similarly if we use replace() method on certain string object then whether it will create new string object or it will modify the existing object?

Thanks

Naveed
But i read in HFS that as per final JSP sepcs you now can not specify the <scripting-invalid> element through JSP. you have to declare it only in DD for the required JSP. What about this?

regards
naveed
Hi Giju George,

Realy appreciate ur hard work but little ambiguity about Point (14) that " The context and session scopes are not thread safe, while the request scope is thread safe for all practical purposes because only one thread services one request."

But I got the following reference to Servlet Specification 2.3 version. Please refer SRV.2.3.3.3 for more specific information.

It states that,
"Implementations of the request and response objects are not guaranteed to be thread safe. This means that they should only be used within the scope of the request handling thread. References to the request and response objects must not be given to objects executing in other threads as the resulting behavior may be nondeterministic."

What is the difference between these statements.

Thanks.
Naveed
Sorry i missed the second servlet in DD, it was cut & past mistake,
<web-app>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>myclasses.dispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/dispatcher</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>dispatcher1</servlet-name>
<servlet-class>myclasses.dispatcher1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher1</servlet-name>
<url-pattern>/dispatcher1</url-pattern>
</servlet-mapping>

</web-app>
My DD is,

<web-app>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>myclasses.dispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher1</servlet-name>
<servlet-class>myclasses.dispatcher1</servlet-class>
</servlet-mapping>
</web-app>



/*Here are both the servlets,*/
// First servlet
package myclasses;
/*
a bunch of import statements
*/
public class dispatcher extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
req.setAttribute("firstname","Jhon");
req.setAttribute("lastname","David");
RequestDispatcher yourname = req.getRequestDispatcher("dispatcher1");
if (yourname != null) yourname.forward(req,res);
}
}


// Second servlet

package myclasses;
/*
a bunch of import statements
*/
public class dispatcher1 extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String fname, lname;
fname = (String)req.getAttribute("firstname");
lname = (String)req.getAttribute("lastname");
PrintWriter out = response.getWriter();
out.println("<p>Hello, " + lname + " " + fname + "</p" );
}
}

myclasses directory is, WEB-INF/classes/my classes.
If i don't use dispatcher(comment out the forward()) in the first servlet and just print to
the browser then it prints. But when i use the dispatcher mechanism it gives 404 error.

naveed
I am using this getRequestDispatcher() in my code to forward a request (from one servlet ) to a resource (another servlet). But it is not working fine and display 404 error. I have the following queries, can any body answer to them.

1. Are both the servlet must be mapped or registered in web.xml.?
2. Are the servlets must be in certain packeges or we can use them from within WEB-INF/classes directory. If we can use them then what will be the path to the getRequestDispatcher() in case of Context and Request. I know the problem is with the path.

Naveed


Hi all,

- What is the difference between .tld file and tag file (.tag or .tagx) ?

- Whether the tag file (.tag or .tagx) is necessary whenever we are implementing tag liberaries or we can avoid it while using JSP 2.0 ?

- Can i find any free tutorial on tag liberaris using the latest techniques
of JSP 2.0 (good if open source & downloadable).

Thanx.

Naveed
Nathaniel,

You might have misunderstood and not like that what
you have said but it is exactly like what i have written.
Any way, i need a quick solution. Can any body lists the steps
to create a new application using Tomcat 5.0 while not using the
default setup (servlets & invoker)???

thnx.

Naveed
20 years ago
Hi all,

I have created new application but when i start Tomcat 5.0 it prints the following error in DOS windown for my application while it loads all its other applications successfully and i can
use the examples of servlets & JSP.

Error is:

Installing web application at context path /myapp from URL D:/Jakarta-tomcat-5\webapps\myapp
jul 15,2004 11:50:00 AM org.appache.commons.digester.Digester fatal error
SEVER: Parse Fatal Eorror at line 2 column 6: The processing instruction target matching "[xX][mM][lL] is not allowed
org.xml.sax.SAXParse Exception: The processing instruction target matching
"[xX][mM][lL] is not allowed

Directory structure is,
/webapps/myapp/WEB-INF/web.xml
/webapps/myapp/WEB-INF/classes/ (all java classes are here)
/webapps/myapp/myapp.xml

---contents of myapp.xml---
<Context path="/myapp" docbase="" debug = "0" privileged="true">
</Context>

---contents of web.xml---
<web-app>
<servlet>
<servlet-name>s1</servlet-name>
<servlet-class>classes.homeservlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>s1</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>

needs help.

Thnx
Naveed
20 years ago
Q1. In what respect does Tomcat 5 differ from Tomcat 4.0.3 regarding creating new separate web application while not depending on the defult context?

Q2. Why the server.xml file of Tomcat5 does not contain <Context path> element? What are the other configuration parameters that are not present or not configured in Tomcat5 and was in Tomcat 4.0.3?

Q3. What are the new additional parameters that must be configured before creating new web application (while not relaying on the default)?

Thnx.
Naveed
20 years ago