This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Why execute twice doGet mothed in servlet! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why execute twice doGet mothed in servlet!" Watch "Why execute twice doGet mothed in servlet!" New topic
Author

Why execute twice doGet mothed in servlet!

xiaojun chen
Greenhorn

Joined: Dec 17, 2002
Posts: 7
I using MVC formwork in UI. When Jsp file link a css file. So it will be execute twice doGet mothed in servlet. When I don't link this css file. It will be Ok. Please tell me what problem? Web container is weblogic. :roll:
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
This is not a web services question.
Post this to either the "WebLogic" forum or the "Servlets" forum.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Moved to the Servlets Forum.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
This sounds to me like a mapping problem in your web.xml. When the browser loads the result of your servlet execution, it sees the link to the css. The browser then makes a get request to the server to load your css. Now, if your mapping causes this get request to be routed to the servlet, this would result in the doGet method being call for your css. Make sure your mapping is such it will only get called on the appropriate get requests.


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

I think Carl is correct. I'm betting that you are using a relative path to your css; something like:

Changing the relative path to a full path will most likely solve your problem.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
xiaojun chen
Greenhorn

Joined: Dec 17, 2002
Posts: 7
Yes, I think you are right. But how to set up web.xml and how to link that css. My jsp file link css is the following.
<link href="test.css" rel="STYLESHEET" type="text/css">
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Since the CSS is grabbed by the browser just like any other resource, why not use the HTML <base> tag to establish the base url? Then the browser will look relative to that base. You should not have to do anything to web.xml.
Bill
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
What I'm afraid is he has a servlet mapping like

And the link to the style sheet is:
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why execute twice doGet mothed in servlet!
 
Similar Threads
URL getting loaded twice
Why execute twice doGet mothed in servlet.
Where is doGet() in JSF?
In Weblogic, service() being called twice
Why did execute twice doGet mothed in servlet!