In general: No. Having ulcers does not protect you from catching the flu. But that "no" is an oversimplification. The devil is indeed in the details.
The innate immune system and the adaptive immune system have to be considered. The reasoning given in the question is in principle largely only applicable to the innate system.
The adaptive immune system is highly specific. When there is a response to one virus then a different virus will be new to this system. That will result in that system having to start from scratch fighting it. To make matters more complicated, both systems interact and the above explanation is almost a grossly reduced picture of what might be going on.
It depends on what an infection is, where it occurs, what is doing the infection etc. Some vaccines are just a perfect fit for the description in question. But to "improve resistance to coming infective disease" would then have to be modified into "improve resistance to coming infective disease of the same or very similar kind".
Examples against "one infection protects against a second" are quite numerous:
In microbiology, coinfection is the simultaneous infection of a host by multiple pathogen species. In virology, coinfection includes simultaneous infection of a single cell by two or more virus particles. An example is the coinfection of liver cells with Hepatitis B virus and Hepatitis D virus, which can arise incrementally by initial infection followed by superinfection.
A superinfection is a second infection superimposed on an earlier one, especially by a different microbial agent of exogenous or endogenous origin, that is resistant to the treatment being used against the first infection. Examples of this in bacteriology are the overgrowth of endogenous Clostridium difficile which occurs following treatment with a broad-spectrum antibiotic, and pneumonia or septicemia from Pseudomonas aeruginosa in some immuno-compromised patients.
HIV superinfection (also called HIV reinfection) is a condition in which a person with an established human immunodeficiency virus infection acquires a second strain of HIV, often of a different subtype. The HIV superinfection strain (a recombinant strain) appears when a person becomes simultaneously infected by two different strains, allowing the two viruses to exchange genetic material, resulting in a new unique strain that can possess the resistances of both previous strains. This new strain co-exists with the two prior strains and may cause more rapid disease progression or carry multiple resistances to certain HIV medications.
On the other hand, if you define infection as "like, having bacteria" then being infected by several of them does (or at least might) protect you. That is of course a philosophical stretch in definitions for most aspects of medicine. But there is some evidence of varying degrees for bacteria, fungi, different forms of viruses and parasites infecting – or less stretchy: colonising – a host and having more beneficial than detrimental effects.
That does not only involve pure infighting between those species. (Like beneficial microbiome species outcrowding the bad ones, or producing chemicals that are toxic to the unwanted invaders, or just good ones eating the bad ones.) There is also some spillover along the lines of reasoning in the question, for example:
An Ocular Commensal Protects against Corneal Infection by Driving an Interleukin-17 Response from Mucosal γδ T Cells
Mucosal sites such as the intestine, oral cavity, nasopharynx, and vagina all have associated commensal flora. The surface of the eye is also a mucosal site, but proof of a living, resident ocular microbiome remains elusive. Here, we used a mouse model of ocular surface disease to reveal that commensals were present in the ocular mucosa and had functional immunological consequences. We isolated one such candidate commensal, Corynebacterium mastitidis, and showed that this organism elicited a commensal-specific interleukin-17 response from γδ T cells in the ocular mucosa that was central to local immunity. The commensal-specific response drove neutrophil recruitment and the release of antimicrobials into the tears and protected the eye from pathogenic Candida albicans or Pseudomonas aeruginosa infection. Our findings provide direct evidence that a resident commensal microbiome exists on the ocular surface and identify the cellular mechanisms underlying its effects on ocular immune homeostasis and host defense.