Chetan Natu

Greenhorn
+ Follow
since Dec 03, 2005
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 Chetan Natu

Have you tried by dropping the "/" in the Form action? I think this will work...
9 years ago
To put it even more simply,

A Web-Server (By definition) acts as a traffic director between a client (user) and the application (webapplication)
A Web-Server (Colloquially, also confused with web container) is the repository program which helps the application(web application) to execute

A Web Application is the program which the client (user) wants to access over the net.

Hope that helps.
9 years ago
Hi Gurdarshan,

If you remember, there is a page directive for the JSPs



amongst other things, if you have not mentioned this attribute for page in the JSP, by default session is activated for the JSPs, so even if you do request.getSession(false) in the code, it won't matter, because session object is already associated with your JSP (implicit object). So if you do not want the session then use the directive listed above.

If you could explain what kind of resources you are associating with the user, I might be in a better position to discuss a better work-around with you for the problem.
9 years ago
JSP
Hi Harshana,

Yes, it does depend on the context under which you are looking at a servlet. Rather to rephrase that, let me say that it all depends on the role you are playing.

If you are acting as a web-designer (JSP, HTML), then a servlet would be a backend for you, but if you look at the application as a webapp developer in that case a servlet is just one component in the middle-ware and not a backend.

From the interviewer perspective, if I am interviewing you for a UI-developer post, then I might accept servlets being a backend, but if I am interviewing you for a post of a developer, then I would not accept the answer.
9 years ago
If nothing seems to work, then just copy paste the code into the reply window and enclose it with the code tag like this

Hi Eric,

I am going to provide you with a totally different solution than any which has been discussed here.

If I read correctly, you need to read a file into your web application and you are going to port the file along with the application wherever you host it. First and foremost do not use hard-coded absolute path, as has been suggested by some. This will tie your application down to the exact directory structure and becomes useless on any other kind of requirement.

To open a file you are going to need absolute path to the file so we go about getting the absolute path (sounds contradictory , read on) without having to change the code or disturbing the application.

There is a method in ServletContext interface called getRealPath this method coverts the virtual path of the application into an absolute path depending on the App Server + OS at runtime. So regardless of where you have deployed the application, this method will always give you the absolute path to the context of your web app, plus you don't even have to bother about confusion of slash (/) or backslash (\). This method returns a string, which is appropriate for your situation.

So get the real path to the context, attach the filename (with subdirectories if that applies) and then open this using the normal IO methods.

Hope that helps
9 years ago

maheshm morem wrote:hi sir,
i want to call the html from servlet. i am serching database of user login from servlet if the user is rigth than it goes to main page so my main page is of the html so want to call it from servlet , plese tell me how to call it?



Hi Mahesh,

you must be writing the code to search Database for a user in some Servlet code. In that servlet code you need to add the two lines that Tom has mentioned. If at all you want some kind of a message back to the page (e.g., you want to display the username on the page), then instead of home.html you will need to use some JSP file and retrieve the data in the JSP file using custom tags or JSTL or a simple scriptlet.

How to do that in JSP? Ask the question in the JSP forum...
9 years ago

Harshana Dias wrote:Hi,

We can say Servelts are back end right? An interviewer once said "Servlets are not back end and for example Spring, EJB do". Is it right? Even spring MVC internally uses servlets to handle the requests right?

Thank You.



Though I do agree with what Tom has mention ed, I would be loathe to call a Servlet as a back-end. To me, a back-end generally means a component which is either a data-storage mechanism, data-persistence mechanism or if I really want to ignore layered application design, business logic.

I can write business logic in servlets, but the design of servlets themselves forbid the use of business logic to be written inside it. Hence, personally if I am conducting your interview, I would agree with the statement that servlet can not be termed as a backend...

Servlet are at best part of the service layer, to paraphrase Tom and Bear, if you are a web-developer / Web designer where you focus is only on the user interface then yes Servlets could be thought of as a backend, but if you are talking about an application then Servlets cannot be called as a backend.

Hope that helps.
9 years ago
If you are trying to get a session, why are you casting it to HttpServletRequest?

It's like getting a round peg and trying to insert into a square hole (or vice versa, as per your preferences)

IF.... you refer to the java documentation, in that case you will observe that the getSession Method returns an object of type HttpSession, which you are trying to cast into HttpServletRequest.

Just for the record, HttpSession and HttpServletRequest are in no way related to each other, you cannot use them as an alternate to each other, as they have totally different structure. Hence you are getting the exception.

and there are lots of things that are wrong with the piece of code and exception that you have sent over. Can't really make any head or tail out of it, unless I get to see the entire code.
9 years ago
JSP

Gaurav Wadhwani wrote:I still dont get it. They say for large scale applications j2ee is more useful whereas PHP for small scale. However, there are a number of sites which are large and made in php. Example facebook. What does largescale mean here?



Just to clarify the point made above, I am posting something I came across while trawling on the internet.

Facebook has realized that there are downsides to using the LAMP stack. Notably, PHP is not necessarily optimized for large websites and therefore hard to scale. Also, it is not the fastest executing language and the extension framework is difficult to use.

and

Facebook’s backend services are written in a variety of different programming languages including C++, Java, Python, and Erlang.



How does Facebook work

Just to answer the specific question raised here. PHP will not be able to scale on it's own it will need the support LAMP stack, whereas in case JavaEE I do not really have to look around for scalability. JavaEE itself provides me help in taking care of it. Hence, it is suggested that for largescale application use JavaEE, while PHP can cater to simple, straightforward, small applications.

My thought would be comparison of PHP and JavaEE is absurd. If at all you want to compare, do so between JSP and PHP, though not really exact, they are almost identical in terms of their responsibilities.
9 years ago

bidmi robson wrote:can anyone please help out.i`m trying to make use of a relay servlet to manage request and responses.i also want to use a dao(data access object) to
connect to the database..the relay and login codes are hereby attached..can you please show me where to place my redirection to another page in the login code.i want to
forward the 2 group of users namely:admin and users to different pages...also how do i write a simple and effective dao
for this web application? thank you ....



I'll take up the part which I have clearly understood.

What you can do is retrieve the information from the web page, while you are authenticating the user, retrieve the type/role of the user from the User Database (You can do this two ways, simple: pick from the database, difficult: map it with your userdirectory). Based on the role simply write an if..else code and redirect to corresponding servlet/JSP/component.

And of course it would help if you could attach the code as well

Hope that helps..

Deepak Kumar Jena wrote:Phoenix, I don't have any intension to test anyone's ability. I had to face this question in an interview. An even my answer was same (as mentioned by you and me), but the interviewer had keep on asking me "what else?". In the end of the interview when I asked her about the answer, she asked me to search for it in google.



How I hate dumb interviewers?

And sorry if I appeared to be questioning your motives, I was actually confused as to why would somebody want to know more than that... Sorry if I gave you that impression.


<edit> sorry name change policy!!! I am still phoenix under a different guise. </edit>
9 years ago
Check your database, normally if you are inserting duplicate primary-key values, you will receive such kind of error...

Can you post the stack trace?
Don't forget to read the resultsetmetadata to extract the field name, size, type etc.,etc., Which will be handy if you want to generate a generalised code to work with any database
<show:example user="<%=request.getParameter("name")%>"

Error shown is "unclosed string literal"....

This is my custom tag code which is not executing successfully, if I replace the expression tag with hard-coded value, it works perfectly. I have been told that expression tag is not compatible with weblogic 6.1!!! Is that true?
14 years ago
JSP