Tuesday, August 29, 2006

Spring MVC and Servlets

I've been using Spring MVC for a variety of web applications. It really does have a lot of nice advantages over Struts making it one of the better request-based frameworks (as opposed to the component based frameworks like Seam.) I came across an interesting use case that doesn't seem to be covered by Spring MVC.

I had a URL mapped to a controller. The URL needed to work for a variety of devices, not just
"full" web browsers like IE and Firefox. In particular it needed to work with a J2ME application. The controller needed to inspect the user agent of the HTTP request, build a model based on this information, and then forward to a view. The view would be different for different devices.

The wrinkle came when the developer working on the J2ME application told me he wanted the view to output a binary data stream. This could be done in a JSP, but is more suited to using a servlet. So I needed to configure a view in Spring MVC that was a servlet.

Spring MVC includes many view implementations. Several JSP-variants, and many other specialized views for working with various technologies such as Jasper Reports, Free Market, POI, PDF, etc. But nothing for a user built servlet like the one I needed to forward to. Seems like kind of a hole in Spring MVC.

Turns out it is not too hard to work around. The key is using the "forward:" prefix. Simply append this to the URL path specified in your servlet mapping, and it will short-circuit the Spring view lookup and forward directly to the desired servlet. So for example, if in your web.xml you had specified "/myServlet" as the mapping to your servlet, then having your controller return something like new ModelAndView("forward:/myServlet", "myModel", model) would forward to your servlet, and allow you to retrieve the model you had built in your controller using a simple request.getAttribute("myModel").

So it was easy to work around, but it still seems like Spring should have a servlet view. Maybe I will try to submit one to them...



technorati tags:,



Blogged with Flock

98 comments:

SomeOnehere said...

"Mostly technical and political,the stuff that bores everyone"

pal,you really wanna tell you're so much different than others..and I think it's too cliche:D

Anonymous said...

Thank you! I was wondering how to use it with servlets! Great!

Unknown said...

great blog to read

job oriented java training | java training course contents | java training topics | best java j2ee training institute in chennai

gowsalya said...

The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this.
Digital Marketing Training in Chennai

Digital Marketing Training in Bangalore

digital marketing training in tambaram

digital marketing training in annanagar

Anonymous said...

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
full stack developer training in annanagar

full stack developer training in tambaram

full stack developer training in velachery

vamsi chennupati said...

It would have been the happiest moment for you,I mean if we have been waiting for something to happen and when it happens we forgot all hardwork and wait for getting that happened.

selenium training in pune

Mounika said...

This is ansuperior writing service point that doesn't always sink in within the context of the classroom. In the first superior writing service paragraph you either hook the reader's interest or lose it. Of course your teacher, who's getting paid to teach you how to write an good essay, 
python training institute in chennai
python training in Bangalore
python training institute in chennai

Unknown said...

This is very good content you share on this blog. it's very informative and provide me future related information.

Data Science training in Chennai
Data science training in bangalore
Data science online training
Data science training in pune

Unknown said...

I think you have a long story to share and i am glad after long time finally you cam and shared your experience.
java training in jayanagar | java training in electronic city

java training in chennai | java training in USA

Anonymous said...

Thank you for this post. Thats all I are able to say. You most absolutely have built this blog website into something speciel. You clearly know what you are working on, youve insured so many corners.thanks
angularjs Training in bangalore

angularjs Training in btm

angularjs Training in electronic-city

angularjs online Training

angularjs Training in marathahalli

Anonymous said...

Useful content, I have bookmarked this page for my future reference.
Python Training in Chennai
Python course in Chennai
RPA Training in Chennai
Angularjs course in Chennai
AWS Certification in Chennai
DevOps Training in Chennai

Shadeep Shree said...

Outstanding information!!! Thanks for sharing your blog with us.
Spoken English Institute in Coimbatore
Spoken English Training in Coimbatore
English Training Institutes in Coimbatore
Spoken English Training
Spoken English Course

Vicky Ram said...

Interesting blog, it gives lots of information to me. Thanks for sharing such a nice blog.

payrollmanagementservice
Article submission sites

mercyroy said...

feeling so good to read your information's in the blog.
thanks for sharing your ideas with us and add more info.
german speaking classes in bangalore
german coaching centers in bangalore
German Training in Nolambur
German Training in Ashok Nagar

Anand said...

This was an nice and amazing and the given contents were very useful and the precision has given here is good.

Java Training in Chennai
Python Training in Chennai
IOT Training in Chennai
Selenium Training in Chennai
Data Science Training in Chennai
FSD Training in Chennai
MEAN Stack Training in Chennai

sultana said...

I am really enjoying reading your well written articles.
It looks like you spend a lot of effort and time on your blog.
I have bookmarked it and I am looking forward to reading new articles. Keep up the good work..
Java Training in Bangalore
Java Training Classes in Bangalore
Java Training Courses in Bangalore
Best Institute For Java Training In Bangalore

Aruna Ram said...

Good work!!! Very creativity post and Thank you for your brief explanation. Keep it up.
Hacking Course in Bangalore
Ethical Hacking Training in Bangalore
Ethical Hacking Classes near me
Ethical Hacking Training in Mogappair
Ethical Hacking Course in Chennai
Ethical Hacking Course in Saidapet

Saro said...

I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing.. Believe me I did wrote an post about tutorials for beginners with reference of your blog. 
best rpa training in bangalore
rpa training in bangalore | rpa course in bangalore
RPA training in bangalore
rpa training in chennai
rpa online training


gowsalya said...

Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
AWS Training in Bangalore

AWS Training in pune

haripriya said...

This is such a great post, and was thinking much the same myself. Another great update.
Microsoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training

VenuBharath2010@gmail.com said...

Wonderful Post. Amazing way of sharing the thoughts. It gives great inspiration. Thanks for sharing.
Xamarin Training in Chennai
Xamarin Course in Chennai
Xamarin Course
Xamarin Training Course
Xamarin Training in OMR
Xamarin Training in Porur
Xamarin Training in Adyar
Xamarin Training in Velachery

Joe said...

Good Job. You have an in-depth knowledge. The way of sharing is very unique.
Informatica Training in Chennai
Informatica Training Center Chennai
Informatica course in Chennai
Informatica Training center in Chennai
Informatica Training chennai
Informatica Training institutes in Chennai
Informatica Training in OMR
Informatica Training in Porur

Aaditya said...

Very nice blog. A great and very informative post, Keep up the good work!

ExcelR Data Science Course in Bangalore


zaintech99 said...

Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.
date analytics certification training courses
data science courses training

istiaq ahmed said...

Cool stuff you have and you keep overhaul every one of us
Data Science Course in Pune

janitha said...

I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business.
data science corse malaysia

malaysiaexcelr01 said...



Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.







BIG DATA COURSE MALAYSIA

Priyanka said...

Attend The Python training in bangalore From ExcelR. Practical Python training in bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Python training in bangalore.
python training in bangalore

VENKAT said...

I'm really impressed with the info you provide in your articles. Hope to see more info from this site

Inplant Training in Chennai
Inplant Training
Inplant Training in Chennai for IT

lucy88 said...

Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!.
Data Science Courses

i Digital Academy said...

Awesome post sir,
really appreciate for your writing. This blog is very much useful...

Hi guyz click here Digital Marketing Training in Bangalore to get the best knowledge and details and also 100% job assistance hurry up...!!

DO NOT MISS THE CHANCE...

Thavaselvan said...

Great Posts with very much valuable information. Great post special thanks to the author.
SAP Training in Chennai | Hardware and Networking Training in Chennai | Pearson Vue Exam Center in Chennai

jaanu said...

Very awesome!!! When I seek for this I found this website at the top of all blogs in search engine.
rpa training in malaysia

Hari said...


Hi,
Your post is very informative. It is helpful to develop my skills in the right way. Persist the great work.
Placement Training in Chennai
Best placement Training institutes in Chennai
Power BI Training in Chennai
Job Openings in Chennai
Pega Training in Chennai
Soft Skills Training in Chennai
JMeter Training in Chennai
Tableau Training in Chennai
Appium Training in Chennai
Placement Training in Porur
Placement Training in Anna Nagar

Mithun said...

Excellent post.
SAP Training in Chennai
SAP ABAP Training in Chennai
SAP Basis Training in Chennai
SAP FICO Training in Chennai
SAP MM Training in Chennai
SAP PM Training in Chennai
SAP PP Training in Chennai
SAP SD Training in Chennai

Prwatech said...
This comment has been removed by the author.
varshaDeepak said...

Best Oracle Training in Chennai

anandhi said...


Excellent information. Very useful to everyone and thanks for sharing this.
Kenya Shared Web Hosting
Dominican Republic Web Hosting
Dominican Republic Jordan Web Hosting
Dominican Republic Kazakhstan Web Hosting
Dominican Republic Web Hosting Korea
Dominican Republic Web Hosting Timor Lestes
Dominican Republic Costa Rica Web Hosting

shiv said...

nice...............
vietnam web hosting
google cloud server hosting
canada telus cloud hosting
algeeria hosting
angola hostig
shared hosting
bangladesh hosting
botswana hosting
central african republi hosting
shared hosting

kani said...

good...
hosting
india hosting
india web hosting
iran web hosting
technology 11 great image sites like imgur hosting
final year project dotnet server hacking what is web hosting
macao web hosting
cloud computing virtual server canada hosting
italy hosting
kenya shared web hosting

kani said...

nice...!
inplant training in chennai

preethi minion said...

nice one..
afghanistan hosting
angola hosting
afghanistan web hosting
bahrain web hosting
belize web hosting
india shared web hosting

kani said...

slovakia web hosting
timor lestes hosting
egypt hosting
egypt web hosting
ghana hosting
iceland hosting
italy shared web hosting
jamaica web hosting
kenya hosting
kuwait web hosting

shri said...

Awesome...
internship report on python
free internship in chennai for ece students
free internship for bca
internship for computer science engineering students in india
internships in hyderabad for cse students 2018
electrical companies in hyderabad for internship
internships in chennai for cse students 2019
internships for ece students
inplant training in tcs chennai
internship at chennai

shalini said...

good.....nice..
category/maintenance-resume
category/manager-resume
category/mechanical-engineering-resume
category/network-engineer-resume
category/officer-resume
category/operations-resume
category/process-associate-resume
category/quality-control-resumes
category/software-engineer-resume

Priyanka said...

Attend The Digital Marketing Course Bangalore From ExcelR. Practical Digital Marketing Course Bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Digital Marketing Course Bangalore.
Digital Marketing Course Bangalore

bavisthra said...

Study Machine learning course bangalore with ExcelR where you get a great experience and better knowledge.Machine learning course bangalore

bavisthra said...

Study Machine learning course bangalore with ExcelR where you get a great experience and better knowledge.Machine learning course bangalore

karthickannan said...

very nice blogs....
coronavirus update
inplant training in chennai
inplant training
inplant training in chennai for cse
inplant training in chennai for ece
inplant training in chennai for eee
inplant training in chennai for mechanical
internship in chennai
online internship

lionelmessi said...

Information you shared is very useful to all of us

Best Python Training Course Institute in Hyderabad

Gaurav said...

I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful.
data science training in gurgaon

360DigiTMG Aurangabad said...

Actually I read it yesterday but I had some thoughts about it and today I wanted to read it again because it is very well written.
ai training in aurangabad

yash said...

I read your post and I found it amazing! thank!


data science course in raipur

Unknown said...

Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
data science training in noida

360digitmgas said...

I finally found great post here.I will get back here. I just added your blog to my bookmark sites. thanks.Quality posts is the crucial to invite the visitors to visit the web page, that's what this web page is providing.
ai training in patna

360digitmgas said...

It is perfect time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I desire to suggest you few interesting things or tips. Perhaps you could write next articles referring to this article. I want to read more things about it!
data science training in coimbatore

Data Science Course said...

I finally found great post here.I will get back here. I just added your blog to my bookmark sites. thanks.Quality posts is the crucial to invite the visitors to visit the web page, that's what this web page is providing.

Data Science Course

Data Science Training said...

It has fully emerged to crown Singapore's southern shores and undoubtedly placed her on the global map of residential landmarks. I still scored the more points than I ever have in a season for GS. I think you would be hard pressed to find somebody with the same consistency I have had over the years so I am happy with that.

Data Science Training

BestTrainingMumbai said...

This content is very considered and well-thought. You are a distinctive thinker. You have put up the unique points to bring up specific points. Please continue doing such good work.
SAP training in Mumbai
SAP course in Mumbai
SAP training institute Mumbai

BestTrainingKolkata said...

If all the writers who pen down articles would give a thought to write topic specific articles like you, then more number of readers would read their content.
SAP training in Kolkata
SAP course in kolkata
SAP training institute in Kolkata

Sowmiya R said...

Your info is really amazing with impressive content..Excellent blog with informative concept.
Oracle Training | Online Course | Certification in chennai | Oracle Training | Online Course | Certification in bangalore | Oracle Training | Online Course | Certification in hyderabad | Oracle Training | Online Course | Certification in pune | Oracle Training | Online Course | Certification in coimbatore

360digitmg said...

This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
data science institute in ecil

360DigiTMG said...

I am a new user of this site so here i saw multiple articles and posts posted by this site,I curious more interest in some of them hope you will give more information on this topics in your next articles.
data science course in hyderabad
business analytics course in hyderabad
data analytics course in hyderabad

tejaswini said...

Personally I think overjoyed I discovered the blogs.pmp certification in malaysia

360DigiTMG said...

Actually I read it yesterday but I had some thoughts about it and today I wanted to read it again because it is very well written.
360 DigiTMG data analytics courses hyderabad

Tableau Course in Raipur - 360DigiTMG said...

Amazing post found to be very impressive while going through this post. Thanks for sharing and keep posting such an informative content.

360DigiTMG Business Analytics Course

vivekvedha said...

Interesting blog, it gives lots of information to me. Thanks for sharing such a nice blog.

acte velachery reviews complaints

acte tambaram reviews complaints

acte anna nagar reviews complaints

acte porur reviews complaints

acte omr reviews complaints

anand said...

amazing post
Software Testing Training in Chennai | Certification | Online
Courses

Software Testing Training in Chennai

Software Testing Online Training in Chennai

Software Testing Courses in Chennai

Software Testing Training in Bangalore

Software Testing Training in Hyderabad

Software Testing Training in Coimbatore

Software Testing Training

Software Testing Online Training

rocky said...

Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next
python training in bangalore

python training in hyderabad

python online training

python training

python flask training

python flask online training

python training in coimbatore
python training in chennai

python course in chennai

python online training in chennai


dhinesh said...

I am really searching for this kind of information, as well as I came to know many things. so please update the latest information, it may be useful for me like beginners.

Full Stack Course in Bangalore

Full Stack Training in Hyderabad

Full Stack Course in Hyderabad

Full Stack Training

Full Stack Course

Full Stack Online Training

Full Stack Online Course


sakthi said...

Excellent information. Very useful to everyone and thanks for sharing this.
Salesforce Training in Chennai

Salesforce Online Training in Chennai

Salesforce Training in Bangalore

Salesforce Training in Hyderabad

Salesforce training in ameerpet

Salesforce Training in Pune

Salesforce Online Training

Salesforce Training


Technogeekscs said...

Really awesome blog!!! I finally found a great post here.I really enjoyed reading this article. Thanks for sharing valuable information.

We are giving all Programming Courses such as You can

Register for a free Online Demo Classes

Data Science Training Institute in Pune
Best Python Online Training
Online AWS Training
Online Data Science Training

manasa said...

This blog is really helpful for me and got a basic knowledge in this topic. Waiting for more updates, kindly keep continuing.

Machine Learning Training in Hyderabad

dilpreetkaur said...

Thank you for sharing such an amazing content
Also you can visit my site and find similar and informative content on the topic :
best digital marketing training institute delhi noida
best facebook marketing services in noida
best Social marketing services in noida
best website development company in noida

ravisynit said...

great java tips At SynergisticIT we offer the best java training california

ai course in raipur - 360DigiTMG said...

Fantastic blog extremely good well enjoyed with the incredible informative content which surely activates the learners to gain the enough knowledge. Which in turn makes the readers to explore themselves and involve deeply in to the subject. Wish you to dispatch the similar content successively in future as well.

artificial intelligence course in raipur

360digitmgas said...

Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work! contact us

Tableau Training in Hyderabad said...



Nice article and thanks for sharing with us. Its very informative




Machine Learning Training in Hyderabad

Tableau Training in Hyderabad said...


Nice article and thanks for sharing with us. Its very informative




DATA SCIENCE TRAINING IN HYDERABAD

EXCELR said...

Im really impressed by it.I am happy for sharing on this blog its awesome blog I really impressed. thanks for sharing. Great efforts. data science training

Rohini said...

I recently came across your article and have been reading along. I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end. I would like to read newer posts and to share my thoughts with you.
data science training

data scientist course said...

I am sure that this is going to help a lot of individuals. Keep up the good work. It is highly convincing and I enjoyed going through the entire blog.
data scientists training

lionelmessi said...

Hi, Thanks for sharing nice articles...

Data Science Training in Hyderabad

Anand Shankar said...

one funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge

Ramesh Sampangi said...

Joining the AI Patasala Best Python Training in Hyderabad program would be a great choice for Python career-minded people.
Python Institutes in Hyderabad

seo freelancer in bangalore said...

Thanks for It is informative post .

SEO Freelancer in Bangalore ,naveedadigital.com offers best SEO freelancing services
in Bangalore for all kinds of businesses.

https://naveedadigital.com/
https://naveedadigital.com/digital-marketing-freelancer-in-bangalore/
https://naveedadigital.com/social-media-marketing-freelancer-in-bangalore/

David Fincher said...

This post is so interactive and informative.keep update more information...
RPA Training in Tambaram
RPA Training in Chennai

360DigiTMG said...

Really impressed! Everything is very open and very clear clarification of issues. It contains true facts. Your website is very valuable. Thanks for sharing.
data analytics courses in hyderabad with placements

Unknown said...

Hi, Thanks for sharing nice articles...

<a href="https://www.dnaglobal.in”>Best CA Company in india</a>

Pavithra Devi said...

This post is so interactive and informative.keep update more information…
SEO Training in Anna Nagar
SEO Training in Chennai

diploma in digital marketing malaysia said...

This post is easy to peruse and acknowledge without forgetting about any subtleties. Extraordinary work! diploma in digital marketing malaysia

cyber pc said...

thanks due to the fact you have been precise-natured to percentage opinion subsequent to us. we are able to continually recognize all you have finished here because I understand you are selected worried thinking about our.! Users can save their personalized presentations locally and online into their accounts using this software. Prezi Pro Account Hack

Let2know said...

i'm able to see which you are an capable at your pitch! i'm launching a internet site quickly, and your inform could be very useful for me.. thanks for all your benefit taking place and wishing you all the triumph for your issue.! Microsoft Office 2010 Cracker

Anonymous said...

We current you a extensive selection of good night messages for him that you simply may send. Good Night Wishes For best Friends words and phrases will gladden these people Good Night Messages For Friends

vepsun said...

Best AWS Training provided by Vepsun in Bangalore for the last 12 years. Our Trainer has more than 20+ Years
of IT Experience in teaching Virtualization and Cloud topics.. we are very delighted to say that Vepsun is
the Top AWS cloud training Provider in Bangalore. We provide the best atmosphere for our students to learn.
Our Trainers have great experience and are highly skilled in IT Professionals. AWS is an evolving cloud
computing platform provided by Amazon with a combination of IT services. It includes a mixture of
infrastructure as service and packaged software as service offerings and also automation. We have trained
more than 10000 students in AWS cloud and our trainer Sameer has been awarded as the best Citrix and Cloud
trainer in india.

360digiTMG.com said...

Get dual certification from IBM and UTM Malaysia with the 360DigiTMG Data Science Certification program.
data scientist course in chennai

shanitha said...

waiting for your next post
Nice Post...I have learn some new information.thanks for sharing.

www.galaxyeduworld.com/ said...

If you’re considering pursuing a Master of Business Administration (MBA), enrolling in one of the top MBA colleges in Bangalore is a smart and strategic choice. Known as the Silicon Valley of India, Bangalore is an educational hub with a vibrant culture of innovation that attracts aspiring business professionals. Renowned institutions such as Akash Group of Institutions, Christ University, SBR, Symbiosis Institute, and M.S. Ramaiah College provide exceptional academic programs, state-of-the-art facilities, and a supportive environment that fosters holistic development.

The leading MBA colleges in Bangalore offer a range of specializations, including finance, marketing, human resources, information technology, leadership, and entrepreneurship, making them ideal for students seeking a diverse and comprehensive MBA experience. These programs equip students with the skills and knowledge needed to excel in today’s competitive business landscape.